Platform Change Alert
A flat notice on a train booking, set in accent color.
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { Card } from "@/components/ui/card"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "Eutropia Rail · Your journey",
booking: "Booking ER–4821",
title: "Your platform has changed",
platform: "platform 5",
footnote: "Station update · 14:18 GMT · Departure in 14 minutes",
origin: "York",
destination: "London King’s Cross",
lead: "The 14:32 service now leaves from",
detail:
"across the footbridge. Your coach C seat 24 reservation is unchanged.",
} as const
/** An Alert as a flat notice on a train booking, set in accent ink. */
export default function AlertPlatformChange() {
return (
<div className="flex w-full items-center justify-center rounded-xl border bg-background px-3 py-8 text-foreground [--radius:0.75rem] sm:px-6 dark:[--radius:0.75rem]">
<Card className="w-full max-w-lg gap-0 rounded-xl p-5 shadow-none ring-0">
<div className="mb-2 flex justify-between gap-3">
<Eyebrow>{COPY.eyebrow}</Eyebrow>
<span className="text-sm/5 text-muted-foreground">
{COPY.booking}
</span>
</div>
<p className="mb-5 text-2xl font-medium tracking-tight">
{COPY.origin} <span aria-hidden="true">→</span> {COPY.destination}
</p>
<Alert className="bg-accent p-5 text-accent-foreground">
<AlertTitle className="text-base">{COPY.title}</AlertTitle>
<AlertDescription className="mt-2 text-accent-foreground/80">
{COPY.lead} <strong>{COPY.platform}</strong>, {COPY.detail}
</AlertDescription>
</Alert>
<p className="mt-4 text-xs text-muted-foreground">{COPY.footnote}</p>
</Card>
</div>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const eyebrowVariants = cva("text-eyebrow", {
variants: {
/**
* `default` is a 14px/20px label. `icon` adds a row with a 16px icon
* and a 12px gap; put the icon first and give it `aria-hidden`.
* `mono` and `caps` are 12px/20px uppercase labels with 0.12em
* tracking, in the mono and inherited faces respectively.
*/
variant: {
default: "text-sm/5 font-medium text-eyebrow",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
},
defaultVariants: { variant: "default" },
})
/**
* A short label above a heading, rendered as a `<p>` at weight 500.
* The default is 14px/20px in the kit's eyebrow color. The surrounding
* layout controls the space to the heading. Use `className` to customize
* the typography or color, and `render` to change the element.
*/
function Eyebrow({
className,
variant = "default",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
Installation
pnpm dlx shadcn@latest add @01orbital/alert-platform-changenpx shadcn@latest add @01orbital/alert-platform-changeyarn dlx shadcn@latest add @01orbital/alert-platform-changebunx --bun shadcn@latest add @01orbital/alert-platform-changeMake it yours
- Its words are in
COPYat the top ofcomponents/blocks/alert/alert-platform-change/index.tsx: change them there, not in the markup.
Built from
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.
Last updated on