StealThis .dev

Empty States — Something-went-wrong state

A polished, self-contained error state for failed data loads, built with vanilla HTML, CSS, and JavaScript. It shows a warning illustration, a clear headline, an explanatory line and a copyable faux error code, plus a primary Try-again action that spins and resolves into a success state with a mini recovery chart. A segmented control swaps between server, network, and not-found framings as well as inline-card and full-page layouts.

लैब में खोलें
html css vanilla-js
Targets: JS HTML

Code

Something-went-wrong state

A generic error surface for when a data fetch fails. The card centers a warning illustration, a “Something went wrong” headline, a plain-language detail line, and a copyable faux error code chip (with a one-click copy button and toast). Two actions sit below: a primary Try again button and a secondary Contact support link. Pressing Try again swaps the button into a loading spinner, then either resolves the panel into a friendly success state — complete with an animated recovery chart — or, for the network framing, reports a failure on the first attempt before recovering.

Two segmented controls drive the live demo. The Framing switcher cycles a generic server 500, a network-offline state (distinct illustration and retry behavior), and a not-found framing, each with its own copy, icon, and error code. The Layout switcher toggles between an inline card embedded in faux dashboard chrome and a centered full-page treatment with a subtle radial backdrop.

Everything is keyboard-usable with visible focus rings, the dynamic region is aria-live, and Escape resets a recovered panel back to its error state. The layout holds together down to roughly 360px, honors prefers-reduced-motion, and ships with a small reusable toast() helper — no frameworks, no external assets.