Framed Screenshot Hero
Heading, two-weight description and actions above one product screenshot held in a window frame, with separate light and dark image sources. Use it as the default product-led hero.
How it differs. Text stack on top and a single window frame below it, fully visible inside the page width: title bar, hairline and a raised mat in place of a shadow.
Install
pnpm dlx shadcn@latest add @hazine/hero-framed-screenshotAdds 1 file, 3 shadcn primitives (aspect-ratio, badge, button), 1 Hazine item (@hazine/heading), and 1 package (lucide-react).
First time? Add the registry to components.json
{
"registries": {
"@hazine": "https://api.hazine.dev/r/{name}.json"
}
}Needed once per project. Items resolve each other through the @hazine namespace.
components/blocks/hero-framed-screenshot.tsx, 358 lines
import * as React from "react"
import { ArrowRight } from "lucide-react"
import { cn } from "@/lib/utils"
import { AspectRatio } from "@/components/ui/aspect-ratio"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Heading, type HeadingLevel } from "@/components/hazine/heading"
export interface HeroAction {
label: string
href: string
}
export interface HeroScreenshot {
src: string
/** Shown instead of `src` when an ancestor carries the `dark` class. Leave out to use `src` in both modes. */
darkSrc?: string
/** Says what the screenshot shows, not that it is a screenshot. */
alt: string
/** Intrinsic size in px. The frame takes its aspect ratio from these, so nothing shifts while the file loads. */
width: number
height: number
}
export interface HeroFramedScreenshotProps
extends Omit<React.ComponentProps<"section">, "title"> {
/** Short line in a badge above the heading. Pass null to leave it out. */
announcement?: string | null
title?: string
/** Opening clause of the description, set in the foreground colour. Pass null to leave it out. */
lead?: string | null
description?: string
primaryAction?: HeroAction
/** Pass null to render a single action. */
secondaryAction?: HeroAction | null
/** One line of reassurance under the actions. Pass null to leave it out. */
footnote?: string | null
/** The product screenshot. Without it, and without `media`, the frame shows a sample view drawn from theme tokens. */
image?: HeroScreenshot
/** Replaces the screenshot inside the frame, for a video or a live fragment. It brings its own accessible name. */
media?: React.ReactNode
/** Text in the title bar. The whole bar is decorative and hidden from assistive technology. */
windowTitle?: string
/** Visible caption under the frame. Pass null to leave it out. */
caption?: string | null
align?: "center" | "start"
/** Use "eager" when the hero is the first thing on the page, so the screenshot is not deferred. */
imageLoading?: "lazy" | "eager"
/** Formats the dates and figures of the sample view. It has no effect once `image` or `media` is set. */
locale?: string
/** Defaults to 1 because a hero usually opens the page. Lower it when the page already has a level 1 heading. */
headingLevel?: HeadingLevel
}
const DEFAULT_PRIMARY_ACTION: HeroAction = {
label: "Start a 30 day trial",
href: "#trial",
}
const DEFAULT_SECONDARY_ACTION: HeroAction = {
label: "Open a sample rota",
href: "#sample-rota",
}
const MICRO_LABEL =
"font-mono text-xs font-medium uppercase tracking-wider text-muted-foreground"
const SAMPLE_WEEK = {
label: "Week 46",
from: "2026-11-09",
to: "2026-11-15",
site: "Northgate Clinic",
shifts: 42,
contractHours: 40,
}
const SAMPLE_OPEN_SHIFTS = [
{ name: "Night, Ward 4", date: "2026-11-12", role: "Registered nurse", qualified: 4, premium: 48 },
{ name: "Early, Day surgery", date: "2026-11-13", role: "Theatre nurse", qualified: 2, premium: 36 },
{ name: "Late, Outpatients", date: "2026-11-15", role: "Healthcare assistant", qualified: 6, premium: 60 },
]
/** The people qualified for the first open shift, fewest scheduled hours first. */
const SAMPLE_COVER = [
{ name: "Imani Okafor", initials: "IO", hours: 24 },
{ name: "Tomasz Lindqvist", initials: "TL", hours: 30 },
{ name: "Priya Raman", initials: "PR", hours: 32 },
{ name: "Dale Whitcombe", initials: "DW", hours: 36 },
]
function HeroFramedScreenshotSample({ locale }: { locale: string }) {
const day = new Intl.DateTimeFormat(locale, { weekday: "short", month: "short", day: "numeric", timeZone: "UTC" })
const span = new Intl.DateTimeFormat(locale, { month: "short", day: "numeric", timeZone: "UTC" })
const count = new Intl.NumberFormat(locale)
const money = new Intl.NumberFormat(locale, {
style: "currency",
currency: "USD",
maximumFractionDigits: 0,
signDisplay: "always",
})
const [selected] = SAMPLE_OPEN_SHIFTS
const open = SAMPLE_OPEN_SHIFTS.length
const filled = SAMPLE_WEEK.shifts - open
const premium = SAMPLE_OPEN_SHIFTS.reduce((sum, shift) => sum + shift.premium, 0)
const stats = [
{ label: "Shifts", value: SAMPLE_WEEK.shifts },
{ label: "Filled", value: filled },
{ label: "Open", value: open },
]
return (
<div
role="img"
aria-label={`Week view for ${SAMPLE_WEEK.site}: ${count.format(filled)} of ${count.format(SAMPLE_WEEK.shifts)} shifts filled, and ${count.format(open)} open shifts listed with the staff qualified to cover them and a combined cover premium of ${money.format(premium)}.`}
className="@container"
>
<div className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 border-b border-border px-4 py-3 @2xl:px-6">
<p className="flex items-baseline gap-3">
<span className={MICRO_LABEL}>{SAMPLE_WEEK.label}</span>
<span className="text-sm font-semibold">
<time dateTime={SAMPLE_WEEK.from}>{span.format(new Date(SAMPLE_WEEK.from))}</time> to{" "}
<time dateTime={SAMPLE_WEEK.to}>{span.format(new Date(SAMPLE_WEEK.to))}</time>
</span>
</p>
<p className="text-sm text-muted-foreground">{SAMPLE_WEEK.site}</p>
</div>
<div className="grid @3xl:grid-cols-3">
<div className="@3xl:col-span-2">
<dl className="grid grid-cols-3 divide-x divide-border border-b border-border">
{stats.map((stat) => (
<div key={stat.label} className="px-4 py-3 @2xl:px-6 @2xl:py-4">
<dt className="text-sm text-muted-foreground">{stat.label}</dt>
<dd className="mt-1 text-lg font-semibold tabular-nums @2xl:text-2xl @2xl:tracking-tight">
{count.format(stat.value)}
</dd>
</div>
))}
</dl>
<div className="flex items-baseline justify-between gap-4 px-4 pt-4 pb-2 @2xl:px-6">
<p className={MICRO_LABEL}>Open shifts</p>
<p className={MICRO_LABEL}>Cover premium</p>
</div>
<ul className="divide-y divide-border border-y border-border">
{SAMPLE_OPEN_SHIFTS.map((shift) => (
<li
key={shift.name}
className={cn(
"flex items-center gap-4 px-4 py-3 @2xl:px-6",
shift === selected && "bg-muted/50"
)}
>
<div className="min-w-0 flex-1">
<p className="truncate text-sm font-semibold">{shift.name}</p>
<p className="mt-0.5 truncate text-sm text-muted-foreground">
<time dateTime={shift.date}>{day.format(new Date(shift.date))}</time>
<span className="hidden @md:inline">, {shift.role}</span>
</p>
</div>
<p className="hidden shrink-0 text-sm text-muted-foreground tabular-nums @md:block">
{count.format(shift.qualified)} qualified
</p>
<p className="shrink-0 text-sm font-medium tabular-nums">{money.format(shift.premium)}</p>
</li>
))}
</ul>
<p className="flex items-baseline justify-between gap-4 px-4 py-3 text-sm font-semibold @2xl:px-6">
<span>If all {count.format(open)} are filled today</span>
<span className="shrink-0 tabular-nums">{money.format(premium)}</span>
</p>
</div>
<div className="flex flex-col border-t border-border bg-muted/50 @3xl:border-s @3xl:border-t-0">
<p className={cn(MICRO_LABEL, "px-4 pt-4 pb-2 @2xl:px-6")}>
Qualified for {selected.name}
</p>
<ul className="divide-y divide-border">
{SAMPLE_COVER.map((person) => (
<li key={person.name} className="flex items-center gap-3 px-4 py-3 @2xl:px-6">
<span className="flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium">
{person.initials}
</span>
<span className="min-w-0 flex-1 truncate text-sm font-medium">{person.name}</span>
<span className="flex shrink-0 items-baseline gap-1 whitespace-nowrap">
<span className="text-sm font-semibold tabular-nums">{count.format(person.hours)}</span>
<span className="text-xs text-muted-foreground">
of {count.format(SAMPLE_WEEK.contractHours)} h
</span>
</span>
</li>
))}
</ul>
{/* Pinned to the foot of the rail, level with the total row beside it. */}
<p className="mt-auto flex items-baseline justify-between gap-4 border-t border-border px-4 py-3 text-sm text-muted-foreground @2xl:px-6">
<span>Fewest scheduled hours first</span>
<span className="shrink-0 tabular-nums">{count.format(SAMPLE_COVER.length)} qualified</span>
</p>
</div>
</div>
</div>
)
}
function HeroFramedScreenshotImage({
image,
loading,
}: {
image: HeroScreenshot
loading: "lazy" | "eager"
}) {
const shared = {
width: image.width,
height: image.height,
loading,
decoding: "async",
} as const
// The swap follows the `dark` class, as the theme does. A picture element with a
// prefers-color-scheme source would follow the system setting and could disagree with the page.
return (
<AspectRatio ratio={image.width / image.height}>
<img
{...shared}
alt={image.alt}
src={image.src}
className={cn("size-full object-cover object-top", image.darkSrc && "in-[.dark]:hidden")}
/>
{image.darkSrc && (
<img
{...shared}
alt={image.alt}
src={image.darkSrc}
className="hidden size-full object-cover object-top in-[.dark]:block"
/>
)}
</AspectRatio>
)
}
function HeroFramedScreenshotAction({
action,
variant,
children,
}: {
action: HeroAction
variant: "default" | "outline"
children?: React.ReactNode
}) {
return (
<Button size="lg" variant={variant} className="h-11 max-w-full" asChild>
<a href={action.href}>
<span className="truncate" title={action.label}>
{action.label}
</span>
{children}
</a>
</Button>
)
}
export function HeroFramedScreenshot({
announcement = "Swap requests now settle on their own",
title = "Fill every shift before the week starts",
lead = "Coverboard lists each open shift with the people qualified to take it.",
description = "It prices the cover before you ask, so the rota is settled on Friday and nobody is phoned on Monday morning.",
primaryAction = DEFAULT_PRIMARY_ACTION,
secondaryAction = DEFAULT_SECONDARY_ACTION,
footnote = "Free for teams of up to 10. No card needed.",
image,
media,
windowTitle = "coverboard.example/northgate/week-46",
caption = "The week view: open shifts on one side, who can cover them on the other.",
align = "center",
imageLoading = "lazy",
locale = "en-US",
headingLevel = 1,
className,
...props
}: HeroFramedScreenshotProps) {
const headingId = React.useId()
return (
<section
data-slot="hero-framed-screenshot"
data-align={align}
aria-labelledby={headingId}
className={cn("group @container", className)}
{...props}
>
<div className="mx-auto max-w-6xl px-4 py-16 @3xl:px-6 @3xl:py-24">
<div className="flex flex-col items-start gap-4 group-data-[align=center]:items-center group-data-[align=center]:text-center">
{announcement && (
<Badge variant="secondary" className="max-w-full">
<span className="truncate" title={announcement}>
{announcement}
</span>
</Badge>
)}
<Heading
id={headingId}
level={headingLevel}
className="max-w-3xl text-2xl font-semibold tracking-tight text-balance @2xl:text-4xl"
>
{title}
</Heading>
<p className="max-w-prose text-base leading-relaxed text-pretty text-muted-foreground">
{lead && <span className="font-medium text-foreground">{lead} </span>}
{description}
</p>
<div className="mt-2 w-full">
<div className="flex flex-col gap-3 group-data-[align=center]:justify-center @md:flex-row @md:flex-wrap">
<HeroFramedScreenshotAction action={primaryAction} variant="default">
<ArrowRight aria-hidden="true" className="rtl:rotate-180" />
</HeroFramedScreenshotAction>
{secondaryAction && (
<HeroFramedScreenshotAction action={secondaryAction} variant="outline" />
)}
</div>
{footnote && <p className="mt-3 text-xs text-muted-foreground">{footnote}</p>}
</div>
</div>
<figure data-slot="hero-framed-screenshot-figure" className="mt-10 @3xl:mt-12">
<div className="rounded-xl bg-muted/50 p-1.5 @3xl:p-3">
<div
data-slot="hero-framed-screenshot-window"
className="overflow-hidden rounded-lg border border-border bg-background"
>
<div
aria-hidden="true"
className="flex h-10 items-center gap-3 border-b border-border px-4"
>
<span className="flex w-12 shrink-0 gap-1.5">
<span className="size-2.5 rounded-full border border-foreground/30" />
<span className="size-2.5 rounded-full border border-foreground/30" />
<span className="size-2.5 rounded-full border border-foreground/30" />
</span>
<span className="min-w-0 flex-1 truncate text-center font-mono text-xs text-muted-foreground">
{windowTitle}
</span>
<span className="w-12 shrink-0" />
</div>
{media ??
(image ? (
<HeroFramedScreenshotImage image={image} loading={imageLoading} />
) : (
<HeroFramedScreenshotSample locale={locale} />
))}
</div>
</div>
{caption && (
<figcaption className="mt-3 text-xs text-muted-foreground group-data-[align=center]:text-center">
{caption}
</figcaption>
)}
</figure>
</div>
</section>
)
}
The demo in the preview, 119 lines
import {
HeroFramedScreenshot,
type HeroScreenshot,
} from "@/components/blocks/hero-framed-screenshot"
export default function HeroFramedScreenshotDemo() {
return <HeroFramedScreenshot />
}
// A demo cannot ship image files, so the two sources are small inline drawings of the same
// week view, one per colour mode. A real page passes two exports of its own screenshot.
function drawing(page: string, line: string, ink: string) {
const rows = [150, 214, 278, 342]
.map(
(y) =>
`<rect x='40' y='${y}' width='300' height='14' rx='4' fill='${ink}'/>` +
`<rect x='40' y='${y + 24}' width='180' height='10' rx='4' fill='${line}'/>` +
`<rect x='680' y='${y + 6}' width='64' height='14' rx='4' fill='${ink}'/>` +
`<rect x='0' y='${y + 48}' width='784' height='1' fill='${line}'/>`
)
.join("")
const people = [70, 134, 198, 262]
.map(
(y) =>
`<circle cx='840' cy='${y + 16}' r='16' fill='${line}'/>` +
`<rect x='872' y='${y + 9}' width='180' height='14' rx='4' fill='${ink}'/>` +
`<rect x='1090' y='${y + 9}' width='70' height='14' rx='4' fill='${line}'/>`
)
.join("")
const svg =
`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 420'>` +
`<rect width='1200' height='420' fill='${page}'/>` +
`<rect x='40' y='22' width='220' height='16' rx='4' fill='${ink}'/>` +
`<rect x='0' y='56' width='1200' height='1' fill='${line}'/>` +
`<rect x='40' y='78' width='90' height='30' rx='4' fill='${ink}'/>` +
`<rect x='300' y='78' width='90' height='30' rx='4' fill='${ink}'/>` +
`<rect x='560' y='78' width='60' height='30' rx='4' fill='${ink}'/>` +
`<rect x='0' y='128' width='784' height='1' fill='${line}'/>` +
`<rect x='784' y='56' width='1' height='364' fill='${line}'/>` +
rows +
people +
`</svg>`
return `data:image/svg+xml,${encodeURIComponent(svg)}`
}
const WEEK_VIEW: HeroScreenshot = {
src: drawing("white", "gainsboro", "dimgray"),
darkSrc: drawing("black", "dimgray", "gainsboro"),
alt: "Coverboard week view with three shift totals, four open shifts and the four people qualified to cover the first one.",
width: 1200,
height: 420,
}
function HeroFramedScreenshotImageSources() {
return (
<HeroFramedScreenshot
image={WEEK_VIEW}
imageLoading="eager"
caption="Two files, one frame: the light export shows by default and the dark export takes over under the dark class."
/>
)
}
function HeroFramedScreenshotStartAligned() {
return (
<HeroFramedScreenshot
align="start"
headingLevel={2}
announcement={null}
title="See who can cover before you ask"
lead="Every open shift carries its own shortlist."
description="Coverboard ranks qualified staff by the hours they already hold this week and shows what the swap adds to the wage bill."
primaryAction={{ label: "Open a sample rota", href: "#sample-rota" }}
secondaryAction={{ label: "Read the scheduling guide", href: "#guide" }}
footnote={null}
/>
)
}
function HeroFramedScreenshotSingleAction() {
return (
<HeroFramedScreenshot
announcement={null}
secondaryAction={null}
footnote={null}
caption={null}
windowTitle="Coverboard"
/>
)
}
function HeroFramedScreenshotOverflow() {
return (
<HeroFramedScreenshot
announcement="Swap requests, overtime approvals and agency bookings now settle on their own across every site"
title="Fill every shift on every ward, in every clinic and on every on-call line, before the week starts and without one phone call"
lead="Coverboard lists each open shift with the people qualified to take it, across wards, theatres, outpatient rooms and on-call lines."
description="It prices the cover before you ask, compares it with the agency rate, checks rest periods against the working time rules and sends the offer to the person with the fewest scheduled hours, so the rota is settled on Friday and nobody is phoned on Monday morning."
primaryAction={{
label: "Start a 30 day trial for every clinic in your group",
href: "#trial",
}}
secondaryAction={{
label: "Open the sample rota for a 400 bed teaching hospital",
href: "#sample-rota",
}}
footnote="Free for teams of up to 10 people on a single site. No card needed, no sales call, and you can export every rota you build during the trial."
windowTitle="coverboard.example/northgate-and-riverside-clinics/rota/2026/week-46/open-shifts?ward=4&view=cover"
caption="The week view for Northgate Clinic in week 46: shift totals along the top, open shifts with their cover premium on one side, and the people qualified for the selected shift on the other."
/>
)
}
export const scenarios = {
"image-sources": HeroFramedScreenshotImageSources,
"start-aligned": HeroFramedScreenshotStartAligned,
"single-action": HeroFramedScreenshotSingleAction,
overflow: HeroFramedScreenshotOverflow,
}
Props15
- announcement
- string | null = "Swap requests now settle on their own"
- Short line in a badge above the heading. Pass null to leave it out.
- title
- string = "Fill every shift before the week starts"
- lead
- string | null = "Coverboard lists each open shift with the people qualified to take it."
- Opening clause of the description, set in the foreground colour. Pass null to leave it out.
- description
- string = "It prices the cover before you ask, so the rota is settled on Friday and nobody is phoned on Monday morning."
- primaryAction
- HeroAction = DEFAULT_PRIMARY_ACTION
- secondaryAction
- HeroAction | null = DEFAULT_SECONDARY_ACTION
- Pass null to render a single action.
- footnote
- string | null = "Free for teams of up to 10. No card needed."
- One line of reassurance under the actions. Pass null to leave it out.
- image
- HeroScreenshot
- The product screenshot. Without it, and without `media`, the frame shows a sample view drawn from theme tokens.
- media
- React.ReactNode
- Replaces the screenshot inside the frame, for a video or a live fragment. It brings its own accessible name.
- windowTitle
- string = "coverboard.example/northgate/week-46"
- Text in the title bar. The whole bar is decorative and hidden from assistive technology.
- caption
- string | null = "The week view: open shifts on one side, who can cover them on the other."
- Visible caption under the frame. Pass null to leave it out.
- align
- "center" | "start" = "center"
- imageLoading
- "lazy" | "eager" = "lazy"
- Use "eager" when the hero is the first thing on the page, so the screenshot is not deferred.
- locale
- string = "en-US"
- Formats the dates and figures of the sample view. It has no effect once `image` or `media` is set.
- headingLevel
- HeadingLevel = 1
- Defaults to 1 because a hero usually opens the page. Lower it when the page already has a level 1 heading.
Also accepts every prop of Omit<React.ComponentProps<"section">, "title">.
Accessibility
- Pattern
- Landmarks and headings
- Keyboard
- Nothing to operate. The item has no focusable parts.
- Screen reader
A section labelled by its heading, whose level is a prop. The screenshot is a figure with a caption and descriptive alt text (the built-in sample view is one labelled image), the window title bar is hidden from assistive technology, and the actions are links.
- Reduced motion
- No motion. Colour transitions only.
- Checked
- Not checked yet. Automated results appear here once CI has run.
Dependencies5
- aspect-ratio
- badge
- button
- @hazine/heading
- lucide-react
Filled chips are registry items the CLI adds for you. Outlined chips are npm packages.
Tokens shipped0
None. The item is styled by the tokens your theme already has.