Offline Save Alert
A notice explaining a save waiting to sync, on a game launcher card.
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: "Valdrada Games · Mossbound",
save: "Save 02",
title: "Saved here. Cloud sync is waiting.",
description:
"Your progress at the Glass Orchard is safe on this device. We’ll sync it when your connection returns. Stay on this device until then.",
saved: "Local save · 21:46",
playTime: "Play time · 08h 32m",
} as const
/** An Alert that explains a save waiting to sync, on a game launcher card. */
export default function AlertOfflineSave() {
return (
<div className="flex w-full items-center justify-center rounded-xl border bg-background px-3 py-8 text-foreground [--radius:0.5rem] sm:px-6 dark:[--radius:0.5rem]">
<Card className="w-full max-w-md gap-0 rounded-lg border p-5 shadow-none ring-0">
<div className="mb-5 flex justify-between gap-4">
<Eyebrow>{COPY.eyebrow}</Eyebrow>
<span className="text-sm/5 text-muted-foreground">{COPY.save}</span>
</div>
<Alert
role="status"
className="rounded-sm border-primary bg-muted p-5 text-foreground"
>
<AlertTitle className="text-base">{COPY.title}</AlertTitle>
<AlertDescription className="mt-2">
{COPY.description}
</AlertDescription>
</Alert>
<div className="mt-5 flex justify-between gap-4 font-mono text-xs text-muted-foreground">
<span>{COPY.saved}</span>
<span>{COPY.playTime}</span>
</div>
</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-offline-savenpx shadcn@latest add @01orbital/alert-offline-saveyarn dlx shadcn@latest add @01orbital/alert-offline-savebunx --bun shadcn@latest add @01orbital/alert-offline-saveMake it yours
- Its words are in
COPYat the top ofcomponents/blocks/alert/alert-offline-save/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