Skip to main content

Card

Info:Layout html svelte astro Success: coverage 51/51

A surface container that groups related content, with optional header and footer regions.

Live demo

live · @xoji/astro

Card

Plain surface

The default card — a quiet panel that groups related content with no extra ceremony.

Interactive

hover me

Lifts on hover and grows a focus-within ring — for cards that behave as a single clickable target.

Compact

Tighter padding and inner spacing for dense, list-like layouts.

With header & footer

Cards expose header, default, and footer slots. The body sits between two faintly ruled regions, so a title and an action row frame the content without any manual dividers.

Success:stable Info:v1 surface

Toned — a leading accent bar

Set tone to mark a card with a colored edge; leave it off for the plain neutral surface.

Accents

accent
accent-2
accent-3
accent-4
neutral

Statuses

success
info
warn
danger

Named hues

red
orange
yellow
green
blue
purple
brown
pink
cyan
gray
white
black

Overlay surface

The translucent variant for cards that float over content — popovers, menus, command palettes.

Card is the workhorse surface: a bordered, elevated panel that frames related content as one unit. It lays its three regions (header, body, footer) out in a column with consistent spacing; the header and footer are real light-DOM parts (.xoji-card__header / .xoji-card__footer), so the same structure renders identically across every binding.

An overlay variant swaps the surface for the translucent treatment used inside popovers and menus; a compact size tightens the padding; an interactive variant adds a hover elevation lift plus a focus-within ring for cards that act as a single clickable target. That last one is presentational only: it styles the surface but adds no behavior, so the consumer wraps the clickable content in a real <button> or <a> for keyboard and screen-reader semantics.

When to use

How this component composes with the rest of the set.

Use Card as the frame for any grouped content: forms, media, summaries, list items.
For a clickable card, set interactive and wrap the content (or the whole region) in a real <button> or <a>; the variant supplies the hover/focus affordance but no behavior.
Pair the overlay variant with floating surfaces (popovers, menus, toasts) so the card matches their translucent treatment.

Props

4 props, straight from the manifest.

PropTypeDefaultBindingsDescription
overlay boolean false
html svelte astro
The translucent overlay surface, for cards floating over content (popovers, menus).
interactive boolean false
html svelte astro
Adds a hover elevation lift and a focus-within ring for cards that act as a single clickable target. Presentational only: wrap the clickable content in a real button or link.
compact boolean false
html svelte astro
Tightens the padding and inner spacing for dense layouts.
tone FullTone
accent neutral danger success warn info accent-2 accent-3 accent-4 red orange yellow green blue purple brown pink cyan gray white black
html svelte astro
Adds a leading-edge accent bar in the chosen tone (any semantic role, accent variant, or named hue). Omit it for the plain neutral surface.

Appearance

Variants

default

.xoji-card

The standard elevated surface on the raised background.

overlay

.xoji-card--overlay

The translucent overlay surface, for cards floating over other content.

interactive

.xoji-card--interactive

Hover elevation lift plus a focus-within ring for a clickable card.

Sizes

default

default
.xoji-card

Standard padding.

compact

.xoji-card--compact

Tightened padding and spacing.

States

hover

.xoji-card--interactive:hover

Pointer over an interactive card; the surface lifts and the overlay paints the hover tint.

active

.xoji-card--interactive:active

Interactive card pressed; the lift drops and the overlay paints the press tint.

focus-within

.xoji-card--interactive:focus-within

Keyboard focus lands inside an interactive card: a token-colored ring, plus a transparent outline that becomes real in forced-colors mode.

Anatomy

The named parts that make up the component, with their selectors.

card

.xoji-card

The surface container carrying the variant and size classes.

--font-sans --text-body --leading-normal --fg-0 --bg-1 --border-thin --line --radius-lg --elevation-2 --space-5 --space-4

header

.xoji-card__header

The top region, a heading-weight title for the card.

--text-lg --weight-semibold --leading-tight --fg-0

body

.xoji-card__body

The main content region.

--fg-1

footer

.xoji-card__footer

The bottom region: separated by a top border, drawn in muted ink.

--space-3 --border-thin --line --fg-2

Tokens & coverage

What the component consumes, checked live against what the algorithm produces.

Success:fully covered 51/51 consumed tokens produced default register: 276 tokens

Live coverage check against the xoji-default register (derive(xojiDefault, { anchors })coverComponent(manifest, register)). Every token this component consumes must be a key the algorithm produces.

--accent --accent-2 --accent-3 --accent-4 --bg-1 --black --blue --border-normal --border-thick --border-thin --brown --cyan --danger --duration-fast --ease-standard --elevation-2 --elevation-4 --fg-0 --fg-1 --fg-2 --font-sans --gray --green --info --leading-normal --leading-tight --line --line-2 --neutral --orange --pink --purple --radius-lg --red --ring --space-1 --space-2 --space-3 --space-4 --space-5 --state-hover --state-press --success --surface-overlay --surface-overlay-border --text-body --text-lg --warn --weight-semibold --white --yellow

Slots

default
html svelte astro

The card body content.

header
html svelte astro

The card title region, rendered above the body.

footer
html svelte astro

The card footer region, rendered below the body with a top border.

Accessibility

Card is a plain surface container with no implicit role; put semantic elements (headings, lists, buttons) inside it.
The interactive variant is presentational only: it adds no role or tab stop. Wrap the clickable target in a native <button> or <a> so keyboard and screen-reader semantics come for free.
The focus ring is driven by :focus-within, so it appears whenever the real interactive element inside the card takes focus.
Focus is shown with a token ring and a transparent outline that the forced-colors base rule promotes to a real system outline.

Code

Regions and variants

Header, body, and footer regions; the overlay, compact, and interactive variants.

<xoji-card>
	<h3 slot="header">Monthly report</h3>
	<p>Revenue is up 12% over last month, driven by the new onboarding flow.</p>
	<div slot="footer">Updated 2 hours ago</div>
</xoji-card>

<xoji-card overlay compact>
	<p>A compact card on a translucent overlay surface.</p>
</xoji-card>

<xoji-card interactive>
	<h3 slot="header">Pricing</h3>
	<p>See every plan and what is included.</p>
	<a slot="footer" href="/pricing">View plans</a>
</xoji-card>
<script lang="ts">
	import { Card } from "@xoji/svelte";
</script>

<Card>
	{#snippet header()}<h3>Monthly report</h3>{/snippet}
	<p>Revenue is up 12% over last month, driven by the new onboarding flow.</p>
	{#snippet footer()}Updated 2 hours ago{/snippet}
</Card>

<Card overlay compact>
	<p>A compact card on a translucent overlay surface.</p>
</Card>

<Card interactive>
	{#snippet header()}<h3>Pricing</h3>{/snippet}
	<p>See every plan and what is included.</p>
	{#snippet footer()}<a href="/pricing">View plans</a>{/snippet}
</Card>
---
import { Card } from "@xoji/astro";
---

<Card>
	<h3 slot="header">Monthly report</h3>
	<p>Revenue is up 12% over last month, driven by the new onboarding flow.</p>
	<div slot="footer">Updated 2 hours ago</div>
</Card>

<Card overlay compact>
	<p>A compact card on a translucent overlay surface.</p>
</Card>

<Card interactive>
	<h3 slot="header">Pricing</h3>
	<p>See every plan and what is included.</p>
	<a slot="footer" href="/pricing">View plans</a>
</Card>