Skip to content

Card

A panel that groups related content, with padding presets, an optional hover state and an optional background image or video.

// Plain markup
import { Card, CardList, CardListItem, CardRow, StatCard } from "@shavin/ui";

Media card

An Image on top and a text stack below. Card has no padding by default, so the image runs to the edges and the body sets its own padding.

Mountain valley with a lake

Summer trip fund

$1,850 of $3,000 saved. At $150 a month you reach the goal in August.

Component Source
<Card className="w-72 overflow-hidden">
  <Image
    src="https://images.unsplash.com/photo-1506744038136-46273834b3fb?w=800&q=80"
    alt="Mountain valley with a lake"
    ratio="16/9"
    radius="none"
  />
  <Flex direction="column" gap="3" className="p-4">
    <Text weight="semibold" className="text-fg">Summer trip fund</Text>
    <Text size="sm" className="text-fg-subtle">$1,850 of $3,000 saved. At $150 a month you reach the goal in August.</Text>
  </Flex>
</Card>

Interactive card

interactive adds a hover border, a shadow and a pointer cursor. It does not add a role or keyboard handling: wrap the card in a link or button, or put one inside it.

Component Source
<a href="#groceries" className="block w-72 rounded-[var(--radius-panel)]">
  <Card interactive padding="md">
    <Flex direction="column" gap="3">
      <Text weight="semibold" className="text-fg">Groceries</Text>
      <Text size="sm" className="text-fg-subtle">$412 of $600 spent this month. 9 days left.</Text>
    </Flex>
  </Card>
</a>

Padding

padding runs from none (the default) to 3xl.

none (0px)
xs (8px)
sm (16px)
md (20px)
lg (24px)
xl (32px)
2xl (40px)
3xl (48px)
Component Source
<Card padding="none">none (0px)</Card>
<Card padding="xs">xs (8px)</Card>
<Card padding="sm">sm (16px)</Card>
<Card padding="md">md (20px)</Card>
<Card padding="lg">lg (24px)</Card>
<Card padding="xl">xl (32px)</Card>
<Card padding="2xl">2xl (40px)</Card>
<Card padding="3xl">3xl (48px)</Card>

Background media

Card takes the shared background media props: bgImage or bgVideo for the media and bgOverlays for legibility layers. Children render above the media. Use it for media-rich product or feature tiles.

Image with a gradient overlay

Field notes

gradient-bottom keeps the caption readable.

Component Source
<Card
  bgImage="https://images.unsplash.com/photo-1789953067753-6a1fcefe07d8?w=1200"
  bgOverlays="gradient-bottom"
  surface="dark-always"
  className="h-[260px] overflow-hidden rounded-[var(--radius-panel)]"
>
  <Flex direction="column" justify="end" gap="2" className="h-full p-6">
    <Heading size="lg">Field notes</Heading>
    <Text size="sm" color="muted">gradient-bottom keeps the caption readable.</Text>
  </Flex>
</Card>

Video with layered overlays

Live backdrop

A dark layer plus a brand tint, in one string.

Component Source
<Card
  bgVideo="https://videos.pexels.com/video-files/39524985/16839566_1920_1080_24fps.mp4"
  bgOverlays="dark-30, (brand)/15"
  surface="dark-always"
  className="h-[260px] overflow-hidden rounded-[var(--radius-panel)]"
>
  <Flex direction="column" align="center" justify="center" gap="2" className="h-full p-6 text-center">
    <Heading size="xl">Live backdrop</Heading>
    <Text size="sm" color="muted">A dark layer plus a brand tint, in one string.</Text>
  </Flex>
</Card>
PropTypeDefault
bgImage

Image URL rendered behind the children with object-cover.

string—
bgVideo

Video URL rendered as a muted, looping, autoplaying background.

string—
bgPoster

Poster for bgVideo. Shown while loading and when the visitor prefers reduced motion.

string—
bgSize

How the media fits the box.

"cover" | "contain""cover"
bgOverlays

Comma-separated overlay layers, composited top to bottom. See Overlay presets below.

string—
bgVideoPaused

Set to "true" to show a still frame instead of playing the video.

"true" | "false"—

Overlay presets

bgOverlays accepts comma-separated shorthand for all overlay types. Presets (below) are the simplest form. You can also use solid colors and gradients:

SyntaxExampleDescription
presetKey"dark-50"Named preset at 100% opacity.
presetKey/opacity"scrim/90"Named preset at custom opacity (0–100).
#hex/opacity"#ff5733/50"Solid hex color with optional opacity.
(token)/opacity"(brand)/30"Semantic token color with optional opacity.
linear(angle, stops)/opacity"linear(45deg, #000/0%, #000/100%)/80"Linear gradient with angle and color stops. Each stop: color/offset%, optionally /opacity after it ("(canvas)/96%/80").
radial(stops)/opacity"radial((brand)/0%, (brand)/100%)/60"Radial gradient with color stops. No angle needed; "at 20% 30%," moves the centre.
fx:key(params)/opacity"fx:fluid-silk(speed=1.2)"Fx backdrop; needs @shavin/fx registered, else falls back to mesh. Params are key=value; quote text with spaces in '…'.

Combine multiple layers with commas. Mix presets, solids, and gradients freely:

bgOverlays="dark-20, (brand)/30, linear(90deg, #000/0%, #000/80%)/70"

Preset keys below are shorthand for common scrim/gradient patterns. The preview column shows the overlay composited over a checkerboard.

PreviewPresetDescription
dark-20Solid black at 20% opacity — subtle darkening for light readability.
dark-30Solid black at 30% opacity — moderate darkening.
dark-50Solid black at 50% opacity — strong darkening for white text legibility.
dark-75Solid black at 75% opacity — heavy darkening for dramatic contrast.
light-20Solid white at 20% opacity — subtle lightening for dark readability.
light-30Solid white at 30% opacity — moderate lightening.
light-50Solid white at 50% opacity — strong lightening for dark text legibility.
gradient-bottomLinear gradient from transparent (top) to 80% black (bottom) — for bottom-aligned text overlays.
gradient-topLinear gradient from transparent (bottom) to 80% black (top) — for top-aligned text overlays.
gradient-radialRadial gradient from transparent (center) to 85% black (edges) — focused-center vignette.
vignetteRadial gradient from transparent (40% radius) to 85% black (edges) — classic vignette.
scrimSoft linear gradient from 10% (top) to 85% (bottom) black — gentle content scrim.

StatCard

trend colours the sub line: up is success, down is danger. alert underlines the value.

Spent this month

$2,340

+8% vs last month

Saved this month

$620

+12% vs last month

Bills due

4

Same as last month

Overdue bills

1

Component Source
<StatCard label="Spent this month" value="$2,340" sub="+8% vs last month" trend="down" />
<StatCard label="Saved this month" value="$620" sub="+12% vs last month" trend="up" />
<StatCard label="Bills due" value="4" sub="Same as last month" trend="flat" />
<StatCard label="Overdue bills" value="1" alert />

CardList and CardListItem

Streaming subscriptionTomorrow
Car loanin 3 days
Component Source
<CardList>
  <CardListItem className="cursor-pointer">
    <span className="flex-1">Streaming subscription</span>
    <span className="text-sm text-fg-muted">Tomorrow</span>
  </CardListItem>
</CardList>

CardRow

Name

Jordan Rivera

Email

jordan@example.com
Component Source
<div className="divide-y divide-hairline rounded-[var(--radius-panel)] border border-hairline bg-surface">
  <CardRow label="Name"><span>Jordan Rivera</span></CardRow>
  <CardRow label="Email"><span className="text-fg-muted">jordan@example.com</span></CardRow>
</div>

Props

PropTypeDefaultDescription
bgVideostring—Background video URL (mp4, webm, etc.). Renders an autoPlay/loop/muted <video> element behind children.
bgImagestring—Background image URL. Renders an <img> with object-cover (default) or object-contain.
bgSize"cover" | "contain"coverBackground media fit. "cover" fills the container (default), "contain" fits within.
bgOverlaysstring—Comma-separated shorthand for overlay layers. Supports presets ("dark-50"), solid colors (#hex or (token)), gradients (linear/radial), and fx backdrops ("fx:dither-waves", "fx:fluid-silk(speed=1.2)"; needs @shavin/fx registered, else falls back to mesh). JSON array of OverlayLayer[] as fallback for advanced cases. Layers composite top-to-bottom.
bgVideoPausedbooleanfalseWhen true, pauses the background video (renders a static poster frame instead of autoplay).
resizableResizableEdges—Make the element user-resizable from these edges: "right", "bottom", "x", "y", "both", true, or a list such as ["left", "bottom-left"]. Off by default.
minWidthnumber—Minimum width in px while resizable (also applied as CSS min-width).
maxWidthnumber—Maximum width in px while resizable (also applied as CSS max-width).
minHeightnumber—Minimum height in px while resizable (also applied as CSS min-height).
maxHeightnumber—Maximum height in px while resizable (also applied as CSS max-height).
resizeStepnumber16Arrow-key resize step in px; Shift multiplies by 4. Default 16.
snapnumber—Round dragged sizes to this grid in px.
lockAspectRatioboolean—Keep the width/height ratio while resizing.
persistKeystring—Remember the size in localStorage under this key.
onResize(size: ResizeSize) => void—Fires once per frame while resizing.
onResizeEnd(size: ResizeSize) => void—Fires when a resize finishes.
resizeHandleResizeHandleVariantlineHandle look: "line" (brand line on hover), "grip" (always-visible pill) or "invisible". Default "line".
resizeColorResizeHandleColorbrand-subtleHandle colour on hover, focus and drag: "brand", "brand-subtle" (softer brand) or "neutral" (monochrome). Default "brand-subtle".
padding"none" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl""none"—
interactive"true" | "false""false"—

StatCard API reference

PropTypeDefault
labelrequired

Short label shown above the metric value.

string—
valuerequired

The primary metric value displayed prominently.

string—
sub

Small line under the value, such as a change.

string—
trend

Colours the sub line: up is success, down is danger, flat leaves it subtle.

"up" | "down" | "flat"—
alert

Underlines the value to flag it. The colour does not change.

booleanfalse
padding

Internal padding preset.

"sm" | "md""sm"
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font