Error pages
Not found, server error and maintenance pages in one card: a big figure in the accent that breaks into dots, one line and the way back.
Something broke on our side
We have been told. Trying again in a minute usually works.
Options
Code
import { useState } from "react";
import "./error-pages.css";
const sample = [
{
label: "404",
code: "404",
title: "This page is not here",
text: "The link may be old, or the page has moved.",
actions: [
{ label: "Back to home", href: "#" },
{ label: "Search the site", href: "#" },
],
},
{
label: "500",
code: "500",
title: "Something broke on our side",
text: "We have been told. Trying again in a minute usually works.",
actions: [
{ label: "Try again", href: "#" },
{ label: "Check status", href: "#" },
],
},
{
label: "Maintenance",
code: "15:00",
title: "Back at 15:00 UTC",
text: "We are making a few changes. Nothing of yours is lost.",
actions: [{ label: "Check status", href: "#", quiet: true }],
},
];
/* One error page: a big quiet figure, a title, one line and its actions.
The first action is the main one unless it is marked quiet. */
export function ErrorPage({ code, title, text, actions = [] }) {
return (
<div className="dh-oops-page">
<p className="dh-oops-code" aria-hidden="true">{code}</p>
<h2>{title}</h2>
<p>{text}</p>
<div className="dh-oops-actions">
{actions.map((action, index) => (
<a className={index === 0 && !action.quiet ? "dh-oops-main" : undefined} href={action.href} key={action.label}>
{action.label}
</a>
))}
</div>
</div>
);
}
/* All the pages behind a switch, for showing them off. On a real site, render
one ErrorPage inside the section and card and leave the switch out. */
export function ErrorPages({ pages = sample, start = 0 }) {
const [chosen, setChosen] = useState(start);
return (
<section className="dh-oops">
<div className="dh-oops-card">
<div className="dh-oops-switch" role="group" aria-label="Which page" style={{ "--i": chosen }}>
{pages.map((page, index) => (
<button type="button" aria-pressed={index === chosen} key={page.label} onClick={() => setChosen(index)}>
{page.label}
</button>
))}
</div>
<ErrorPage key={chosen} {...pages[chosen]} />
</div>
</section>
);
}
export function Example() {
return <ErrorPages />;
}/* Three error pages in one: not found, server error and maintenance. The
switch at the top is only for the preview; on a real site, keep one page. */
.dh-oops {
container: dh-oops / inline-size;
padding: 24px;
background: var(--dh-bg, #f7f7f6);
color: var(--dh-fg, #171717);
font-family: inherit;
font-size: 13px;
line-height: 20px;
}
.dh-oops *,
.dh-oops *::before,
.dh-oops *::after {
box-sizing: border-box;
}
.dh-oops-card {
--ease: cubic-bezier(0.23, 1, 0.32, 1);
--accent: var(--dh-accent, #2563ff);
--line: color-mix(in srgb, var(--dh-fg, #171717) 9%, transparent);
display: grid;
grid-template-rows: auto 1fr;
justify-items: center;
max-width: 720px;
min-height: 440px;
margin: 0 auto;
padding: 12px 24px 48px;
border-radius: 14px;
background: var(--dh-raised, #fff);
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
}
/* The switch: three equal options and one raised pill that slides under
the chosen one. --i is the chosen option's place, counted from 0. */
.dh-oops-switch {
position: relative;
display: grid;
grid-template-columns: repeat(3, 92px);
padding: 2px;
border-radius: 8px;
background: var(--dh-well, #ededeb);
}
.dh-oops-switch::before {
content: "";
position: absolute;
top: 2px;
left: 2px;
width: 92px;
height: 24px;
border-radius: 6px;
background: var(--dh-raised, #fff);
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 12%, transparent);
translate: calc(var(--i) * 100%) 0;
transition: translate 0.35s var(--ease);
}
.dh-oops-switch button {
position: relative;
height: 24px;
padding: 0;
border: 0;
border-radius: 6px;
background: none;
color: var(--dh-muted, #5c5c5c);
font: inherit;
font-size: 12px;
font-weight: 500;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
transition: color 0.15s var(--ease);
}
.dh-oops-switch button[aria-pressed="true"] {
color: var(--dh-fg, #171717);
}
.dh-oops-switch button:focus-visible {
outline: 2px solid var(--dh-faint, #8a8a8a);
outline-offset: 1px;
}
.dh-oops-page {
display: grid;
align-content: center;
justify-items: center;
text-align: center;
animation: dh-oops-in 0.5s var(--ease) both;
}
.dh-oops-page[hidden] {
display: none;
}
.dh-oops-page :is(h2, p) {
margin: 0;
font-weight: 500;
}
/* The big figure is the accent, breaking up into dots as it goes down. */
.dh-oops-code {
background: linear-gradient(color-mix(in srgb, var(--accent) 82%, #000), var(--accent));
-webkit-background-clip: text;
background-clip: text;
-webkit-mask-image: linear-gradient(#000 30%, transparent 92%), radial-gradient(circle, #000 1.5px, transparent 1.9px);
mask-image: linear-gradient(#000 30%, transparent 92%), radial-gradient(circle, #000 1.5px, transparent 1.9px);
-webkit-mask-size: auto, 6px 6px;
mask-size: auto, 6px 6px;
padding: 0 0.08em;
color: transparent;
font-size: min(26cqi, 184px);
font-weight: 500;
line-height: 1;
letter-spacing: -0.06em;
font-variant-numeric: tabular-nums;
user-select: none;
}
.dh-oops-page h2 {
margin-top: 4px;
font-size: 16px;
line-height: 24px;
letter-spacing: -0.02em;
}
.dh-oops-page h2 + p {
max-width: 36ch;
margin-top: 2px;
color: var(--dh-muted, #5c5c5c);
font-weight: 400;
}
.dh-oops-actions {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 8px;
margin-top: 20px;
}
.dh-oops-actions a {
display: grid;
place-items: center;
height: 32px;
padding: 0 12px;
border-radius: 8px;
background: var(--dh-raised, #fff);
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
color: var(--dh-fg, #171717);
font-weight: 500;
letter-spacing: -0.01em;
text-decoration: none;
transition:
scale 0.15s var(--ease),
filter 0.15s var(--ease);
}
.dh-oops-actions .dh-oops-main {
background: linear-gradient(color-mix(in srgb, var(--accent) 84%, #fff), var(--accent));
box-shadow:
inset 0 1px 0 rgb(255 255 255 / 0.3),
0 0 0 1px color-mix(in srgb, var(--accent) 78%, #000),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 22%, transparent);
color: var(--dh-on-accent, #fff);
}
.dh-oops-actions a:active {
scale: 0.97;
}
.dh-oops-actions a:focus-visible {
outline: 2px solid var(--dh-faint, #8a8a8a);
outline-offset: 2px;
}
@media (hover: hover) and (pointer: fine) {
.dh-oops-switch button:hover {
color: var(--dh-fg, #171717);
}
.dh-oops-actions a:hover {
filter: brightness(1.06);
}
}
@container dh-oops (max-width: 560px) {
.dh-oops {
padding: 12px;
}
.dh-oops-card {
min-height: 460px;
padding: 12px 20px 40px;
border-radius: 14px;
font-size: 15px;
line-height: 22px;
}
.dh-oops-switch {
grid-template-columns: repeat(3, 1fr);
width: 100%;
}
.dh-oops-switch::before {
width: calc((100% - 4px) / 3);
height: 40px;
}
.dh-oops-switch button {
height: 40px;
font-size: 14px;
}
.dh-oops-code {
font-size: 34cqi;
}
.dh-oops-actions {
flex-direction: column;
align-self: stretch;
justify-self: stretch;
}
.dh-oops-actions a {
height: 44px;
}
}
@keyframes dh-oops-in {
from {
opacity: 0;
transform: translateY(10px);
filter: blur(8px);
}
}
@media (prefers-reduced-motion: reduce) {
.dh-oops-page {
animation: dh-oops-fade 0.2s both;
}
.dh-oops-switch::before,
.dh-oops-actions a {
transition: none;
}
}
@keyframes dh-oops-fade {
from {
opacity: 0;
}
}<section class="dh-oops">
<div class="dh-oops-card">
<div class="dh-oops-switch" role="group" aria-label="Which page" style="--i: 0">
<button type="button" aria-pressed="true">404</button>
<button type="button" aria-pressed="false">500</button>
<button type="button" aria-pressed="false">Maintenance</button>
</div>
<div class="dh-oops-page">
<p class="dh-oops-code" aria-hidden="true">404</p>
<h2>This page is not here</h2>
<p>The link may be old, or the page has moved.</p>
<div class="dh-oops-actions">
<a class="dh-oops-main" href="#">Back to home</a>
<a href="#">Search the site</a>
</div>
</div>
<div class="dh-oops-page" hidden>
<p class="dh-oops-code" aria-hidden="true">500</p>
<h2>Something broke on our side</h2>
<p>We have been told. Trying again in a minute usually works.</p>
<div class="dh-oops-actions">
<a class="dh-oops-main" href="#">Try again</a>
<a href="#">Check status</a>
</div>
</div>
<div class="dh-oops-page" hidden>
<p class="dh-oops-code" aria-hidden="true">15:00</p>
<h2>Back at 15:00 UTC</h2>
<p>We are making a few changes. Nothing of yours is lost.</p>
<div class="dh-oops-actions">
<a href="#">Check status</a>
</div>
</div>
</div>
</section>/* Three error pages in one: not found, server error and maintenance. The
switch at the top is only for the preview; on a real site, keep one page. */
.dh-oops {
container: dh-oops / inline-size;
padding: 24px;
background: var(--dh-bg, #f7f7f6);
color: var(--dh-fg, #171717);
font-family: inherit;
font-size: 13px;
line-height: 20px;
}
.dh-oops *,
.dh-oops *::before,
.dh-oops *::after {
box-sizing: border-box;
}
.dh-oops-card {
--ease: cubic-bezier(0.23, 1, 0.32, 1);
--accent: var(--dh-accent, #2563ff);
--line: color-mix(in srgb, var(--dh-fg, #171717) 9%, transparent);
display: grid;
grid-template-rows: auto 1fr;
justify-items: center;
max-width: 720px;
min-height: 440px;
margin: 0 auto;
padding: 12px 24px 48px;
border-radius: 14px;
background: var(--dh-raised, #fff);
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
}
/* The switch: three equal options and one raised pill that slides under
the chosen one. --i is the chosen option's place, counted from 0. */
.dh-oops-switch {
position: relative;
display: grid;
grid-template-columns: repeat(3, 92px);
padding: 2px;
border-radius: 8px;
background: var(--dh-well, #ededeb);
}
.dh-oops-switch::before {
content: "";
position: absolute;
top: 2px;
left: 2px;
width: 92px;
height: 24px;
border-radius: 6px;
background: var(--dh-raised, #fff);
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 12%, transparent);
translate: calc(var(--i) * 100%) 0;
transition: translate 0.35s var(--ease);
}
.dh-oops-switch button {
position: relative;
height: 24px;
padding: 0;
border: 0;
border-radius: 6px;
background: none;
color: var(--dh-muted, #5c5c5c);
font: inherit;
font-size: 12px;
font-weight: 500;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
transition: color 0.15s var(--ease);
}
.dh-oops-switch button[aria-pressed="true"] {
color: var(--dh-fg, #171717);
}
.dh-oops-switch button:focus-visible {
outline: 2px solid var(--dh-faint, #8a8a8a);
outline-offset: 1px;
}
.dh-oops-page {
display: grid;
align-content: center;
justify-items: center;
text-align: center;
animation: dh-oops-in 0.5s var(--ease) both;
}
.dh-oops-page[hidden] {
display: none;
}
.dh-oops-page :is(h2, p) {
margin: 0;
font-weight: 500;
}
/* The big figure is the accent, breaking up into dots as it goes down. */
.dh-oops-code {
background: linear-gradient(color-mix(in srgb, var(--accent) 82%, #000), var(--accent));
-webkit-background-clip: text;
background-clip: text;
-webkit-mask-image: linear-gradient(#000 30%, transparent 92%), radial-gradient(circle, #000 1.5px, transparent 1.9px);
mask-image: linear-gradient(#000 30%, transparent 92%), radial-gradient(circle, #000 1.5px, transparent 1.9px);
-webkit-mask-size: auto, 6px 6px;
mask-size: auto, 6px 6px;
padding: 0 0.08em;
color: transparent;
font-size: min(26cqi, 184px);
font-weight: 500;
line-height: 1;
letter-spacing: -0.06em;
font-variant-numeric: tabular-nums;
user-select: none;
}
.dh-oops-page h2 {
margin-top: 4px;
font-size: 16px;
line-height: 24px;
letter-spacing: -0.02em;
}
.dh-oops-page h2 + p {
max-width: 36ch;
margin-top: 2px;
color: var(--dh-muted, #5c5c5c);
font-weight: 400;
}
.dh-oops-actions {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 8px;
margin-top: 20px;
}
.dh-oops-actions a {
display: grid;
place-items: center;
height: 32px;
padding: 0 12px;
border-radius: 8px;
background: var(--dh-raised, #fff);
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
color: var(--dh-fg, #171717);
font-weight: 500;
letter-spacing: -0.01em;
text-decoration: none;
transition:
scale 0.15s var(--ease),
filter 0.15s var(--ease);
}
.dh-oops-actions .dh-oops-main {
background: linear-gradient(color-mix(in srgb, var(--accent) 84%, #fff), var(--accent));
box-shadow:
inset 0 1px 0 rgb(255 255 255 / 0.3),
0 0 0 1px color-mix(in srgb, var(--accent) 78%, #000),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 22%, transparent);
color: var(--dh-on-accent, #fff);
}
.dh-oops-actions a:active {
scale: 0.97;
}
.dh-oops-actions a:focus-visible {
outline: 2px solid var(--dh-faint, #8a8a8a);
outline-offset: 2px;
}
@media (hover: hover) and (pointer: fine) {
.dh-oops-switch button:hover {
color: var(--dh-fg, #171717);
}
.dh-oops-actions a:hover {
filter: brightness(1.06);
}
}
@container dh-oops (max-width: 560px) {
.dh-oops {
padding: 12px;
}
.dh-oops-card {
min-height: 460px;
padding: 12px 20px 40px;
border-radius: 14px;
font-size: 15px;
line-height: 22px;
}
.dh-oops-switch {
grid-template-columns: repeat(3, 1fr);
width: 100%;
}
.dh-oops-switch::before {
width: calc((100% - 4px) / 3);
height: 40px;
}
.dh-oops-switch button {
height: 40px;
font-size: 14px;
}
.dh-oops-code {
font-size: 34cqi;
}
.dh-oops-actions {
flex-direction: column;
align-self: stretch;
justify-self: stretch;
}
.dh-oops-actions a {
height: 44px;
}
}
@keyframes dh-oops-in {
from {
opacity: 0;
transform: translateY(10px);
filter: blur(8px);
}
}
@media (prefers-reduced-motion: reduce) {
.dh-oops-page {
animation: dh-oops-fade 0.2s both;
}
.dh-oops-switch::before,
.dh-oops-actions a {
transition: none;
}
}
@keyframes dh-oops-fade {
from {
opacity: 0;
}
}/* The switch shows one page at a time and slides its pill to the chosen option. */
document.querySelectorAll(".dh-oops-card").forEach((card) => {
const options = card.querySelectorAll(".dh-oops-switch button");
const pages = card.querySelectorAll(".dh-oops-page");
options.forEach((option, index) => {
option.addEventListener("click", () => {
option.parentElement.style.setProperty("--i", index);
options.forEach((other) => other.setAttribute("aria-pressed", String(other === option)));
pages.forEach((page, place) => {
page.hidden = place !== index;
});
});
});
});Error pages is not in the Figma file yet.
Use the React or HTML code for now.