Frost Moon Article Card
Article card with a frosted surface and a blue moon rising behind the top corner: a large serif headline, a byline and a reading note that opens in the footer.
import {
Byline,
BylineDescription,
BylineName,
} from "@/components/byline/byline"
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { MoonSphere } from "@/components/orbs/moon-sphere"
import { Text } from "@/components/text/text"
import {
Card,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "After hours / 02",
title: "The hours after everyone has gone home.",
description: "A field guide to the work we do when the day gets quiet.",
author: "Dacian Holt",
byline: "Field notes · 8 min read",
summary: "Read the note",
note: "Some projects need a conversation. Others need a closed door and an uninterrupted hour. The useful part is knowing which one is in front of you.",
} as const
/** A card with a blue moon in its top corner, lit along one limb: a large Geist Serif headline and a short reading note that opens in the footer. */
export default function FrostMoonCard() {
return (
<Card className="theme-frost surface-frost relative isolate min-h-104 w-full max-w-lg min-w-0 gap-8 [--card-spacing:--spacing(8)] min-[42rem]:[--card-spacing:--spacing(10)]">
{/* MoonSphere is lit along its upper-right limb only, and the rest of
the disc is clear. So the whole disc sits inside the card: pushed
past the corner, the lit limb is cut off and only a haze is left.
It is dimmed on a dark page so light text over it stays readable. */}
<MoonSphere
size="min(17rem, 60%)"
moonColor="var(--color-blue-300)"
className="absolute top-6 right-6 dark:opacity-60"
/>
<CardHeader className="relative z-2 grid-cols-[minmax(0,var(--container-md))] justify-between gap-4">
<div>
<Eyebrow variant="mono" className="text-current">
{COPY.eyebrow}
</Eyebrow>
</div>
<CardTitle
role="heading"
aria-level={3}
className="text-2xl/8 font-[450] tracking-[-0.04em] text-pretty @sm/card-header:text-3xl/9"
>
<span className="font-serif font-normal tracking-tight">
{COPY.title}
</span>
</CardTitle>
<CardDescription className="col-span-full w-full min-w-0 text-base/7 text-balance text-current/75">
{COPY.description}
</CardDescription>
</CardHeader>
<CardFooter className="relative z-2 mt-auto flex-wrap justify-between gap-x-6 gap-y-2 text-xs/5">
<Byline size="sm">
<BylineName>{COPY.author}</BylineName>
<BylineDescription>{COPY.byline}</BylineDescription>
</Byline>
<Collapsible className="w-full text-sm/6">
<CollapsibleTrigger className="w-fit cursor-pointer py-1 underline underline-offset-4">
{COPY.summary}
</CollapsibleTrigger>
<CollapsibleContent>
<Text size="sm" className="pt-4" variant="muted">
{COPY.note}
</Text>
</CollapsibleContent>
</Collapsible>
</CardFooter>
</Card>
)
}
import type { ComponentProps } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
type BylineSize = "md" | "sm"
type BylineState = { slot: "byline"; size: BylineSize }
type BylineAvatarState = { slot: "byline-avatar" }
/**
* A person's byline: an optional `BylineAvatar`, then `BylineName` with a
* `BylineDescription` under it, as a `div`. With an avatar it becomes two
* columns: the avatar spans both lines, 16px from the text. Under a quote,
* pass `render={<figcaption />}`; in a centered quote add `w-fit text-left` so it shrinks to fit
* and keeps its text left-aligned.
*
* At `size="md"` (the default) the name is 16px/24px semibold and the
* description 14px/20px muted, 2px apart; a 40px avatar matches the two
* lines. At `size="sm"` both lines are 12px/20px, the name in regular weight,
* the byline of a card footer.
*/
function Byline({
className,
size = "md",
render,
...props
}: useRender.ComponentProps<"div", BylineState> & {
/** The type size: `md` (the default) 16px over 14px, `sm` 12px over 12px for a card footer. */
size?: BylineSize
}) {
return useRender({
defaultTagName: "div",
render,
state: { slot: "byline", size },
props: mergeProps<"div">(
{
className: cn(
"group/byline grid items-center gap-x-4 gap-y-0.5 text-sm/5 has-data-[slot=byline-avatar]:grid-cols-[auto_1fr] data-[size=sm]:text-xs/5",
className
),
},
props
),
})
}
/**
* Holds the person's picture beside the name and description: a stock
* `Avatar`, an orb avatar or an image, 40px recommended. Use
* `render={<div />}` when the artwork has a block root.
*/
function BylineAvatar({
className,
render,
...props
}: useRender.ComponentProps<"span", BylineAvatarState>) {
return useRender({
defaultTagName: "span",
render,
state: { slot: "byline-avatar" },
props: mergeProps<"span">(
{ className: cn("row-span-2 flex", className) },
props
),
})
}
/** The person's name, 16px/24px semibold, held close to the line below; 12px regular in a `sm` byline. */
function BylineName({ className, ...props }: ComponentProps<"span">) {
return (
<span
data-slot="byline-name"
className={cn(
"self-end text-base/6 font-semibold group-data-[size=sm]/byline:text-xs/5 group-data-[size=sm]/byline:font-normal",
className
)}
{...props}
/>
)
}
/**
* The second line under the name, such as a job title, a company, a handle
* or a date, in 14px/20px muted text; 12px in a `sm` byline.
*/
function BylineDescription({ className, ...props }: ComponentProps<"span">) {
return (
<span
data-slot="byline-description"
className={cn("self-start text-muted-foreground", className)}
{...props}
/>
)
}
export { Byline, BylineAvatar, BylineName, BylineDescription }
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` is a 12px/20px label in the mono face, in sentence case like
* the others: the kit sets no label in capitals.
*/
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",
},
},
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: a `p` is
* right when the label stands alone as a line of text; pass
* `render={<span />}` or `render={<div />}` when it sits inside a heading,
* link, button or other inline text, where a `p` is not valid HTML.
*/
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 }
import { cn } from "cn"
/**
* A sphere lit only on one limb, for a moon rising over a dark ground. A
* radial gradient from the lower-left corner runs transparent out to
* `moonColor` at the upper-right edge, so the rest of the disc shows the
* ground behind it. It is decorative and hidden from assistive tech.
*/
function MoonSphere({
className,
size = 256,
moonColor = "oklch(0.65 0.12 55)",
style,
...props
}: React.ComponentProps<"div"> & {
/**
* Diameter: a number of px or any CSS length. `"100cqi"` fills the
* nearest size container, so the sphere follows its box without measuring.
*/
size?: number | string
/** The rim light's color. */
moonColor?: string
}) {
return (
<div
aria-hidden="true"
data-slot="moon-sphere"
className={cn("block rounded-full", className)}
style={{
width: size,
maxWidth: "100%",
background: `radial-gradient(circle at 0% 100%, transparent 60%, ${moonColor} 100%)`,
...style,
height: "auto",
aspectRatio: "1 / 1",
flexShrink: 0,
}}
{...props}
/>
)
}
export { MoonSphere }
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"
// Paragraphs in body content and introductions. It has no width of its own:
// the layout sets the measure. The default sets the foreground color; muted
// steps it down. Over art or a colored ground, pass className="text-current"
// to keep the ink around it. The text under a section's title is
// SectionDescription.
const textVariants = cva("w-full min-w-0 text-balance", {
variants: {
/**
* The text color. `default` (the default) is `foreground`; `muted`
* is `muted-foreground`. For the ink of a colored ground or art, pass
* `className="text-current"`.
*/
variant: {
default: "text-foreground",
muted: "text-muted-foreground",
},
/**
* The text size and line height: `xs` 12px/20px for a footnote or fine
* print; `sm` 14px/24px for the line under a card or panel title; `md`
* (the default) 16px/28px for body copy; `lg` 18px/28px at every width;
* `xl` 18px/28px, then 20px/32px from `sm` for a hero introduction.
*/
size: {
xs: "text-xs/5",
sm: "text-sm/6",
md: "text-base/7",
lg: "text-lg/7",
xl: "text-lg/7 sm:text-xl/8",
},
/**
* Tabular figures: every digit takes the same width, so numbers line up
* in a column and a changing count does not shift the text.
*/
tabular: {
true: "tabular-nums",
false: "",
},
},
defaultVariants: { variant: "default", size: "md", tabular: false },
})
/**
* A paragraph in body content or an introduction, a `p` by default. For
* several paragraphs, pass `render={<div />}` and put your own `p` elements
* inside.
*
* The default is the `foreground` color at regular weight (400, inherited
* from the page unless a parent sets one), and the lines are balanced when it
* wraps. `size` sets the text and its line height: `xs` 12px/20px for a
* footnote or fine print; `sm` 14px/24px for the line under a card or panel
* title; `md` (the default) 16px/28px for body copy in cards, lists and rows;
* `lg` 18px/28px; or `xl` 18px/28px and 20px/32px from `sm` for a hero.
* `variant="muted"` uses the muted text color. On art or a colored ground,
* pass `className="text-current"` to keep the ink around it. `tabular` sets
* tabular figures for numbers that line up or change. The layout controls the
* text's width and spacing. The text under a section's title is
* `SectionDescription`.
*/
function Text({
className,
variant = "default",
size = "md",
tabular = false,
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof textVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "text", variant, size, tabular },
props: mergeProps<"p">(
{ className: cn(textVariants({ variant, size, tabular }), className) },
props
),
})
}
export { Text, textVariants }
Installation
npx shadcn@latest add @01orbital/frost-moon-card-01Make it yours
- Its words are in
COPYat the top ofcomponents/blocks/card/frost-moon-card-01/index.tsx: change them there, not in the markup. - Its look comes from Moon Sphere; each page lists the props that change it.
Built from
npm: @01orbital/font-geist-serif. The CLI installs it for you.
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