Skip to content

Card

A content container with optional media, actions, horizontal layout, and clickable-overlay support.

Import

import { Card } from "@hyzer-labs/ui"

Demo

Card is headless. The dashed outline below is docs scaffolding, added so its box is visible.

padding="md"

<Card padding="md">
	<p>padding="md"</p>
</Card>

Props

NameTypeDefaultNote
padding'none' | 'sm' | 'md' | 'lg''md'Set 'none' to opt out and control padding entirely from your own class.
rounded'none' | 'sm' | 'md' | 'lg''md'
hrefstringMakes the whole card clickable.
ariaLabelstringRequired when href is set.
horizontalbooleanfalse
mediaPosition'start' | 'end''start'
classstringMerged after the hz-card class.
mediaSnippet
childrenSnippet
actionsSnippet

Theme hooks

What this component promises your CSS. The reference theme styles exactly these — from @layer hz-theme, so your unlayered rules win. See Styling Components for the how.

Root class: .hz-card

Data attributes

HookValuesStyles
data-padding'none' | 'sm' | 'md' | 'lg'Lands on .hz-card-content, not the root — which is how media bleeds edge-to-edge while text stays inset. Default md.
data-rounded'none' | 'sm' | 'md' | 'lg'No full rung, unlike the shared Rounded scale. Default md.
data-horizontalpresent when horizontalMedia beside content above 640px.
data-clickablepresent when href is setThe whole card becomes a target; the theme hangs its hover affordances off this together with a treatment class.
data-media-position'start' | 'end'Mirrors the prop. The effect is DOM order, not CSS order — so reading order and visual order cannot disagree.

Custom properties

HookValuesStyles
--hz-card-media-size<length|percentage> — default 40%The media track in horizontal mode; media fills it. Never declared, so set it yourself on .hz-card or an ancestor.

Part classes

HookValuesStyles
.hz-card--outlinedopt-in classA theme treatment, not a prop: pass it via class. Card ships no variant prop because the look is the theme’s call, not the API’s.
.hz-card--elevatedopt-in classThe shadow treatment. Same deal.
.hz-card-titleopt-in classCard never emits this — you bring the heading element at whatever level the page needs, and the class only styles it. Headings aren’t load-bearing for Card the way they are for Modal or Accordion, so this never became API.
.hz-card-mediachild elementThe media wrapper.
.hz-card-contentchild elementThe padded region.
.hz-card-bodychild elementThe default slot wrapper.
.hz-card-actionschild elementThe actions row.
.hz-card-linkchild elementThe overlay anchor, present only when clickable. Its own focus ring would be clipped on rounded cards, so the theme draws the ring on .hz-card itself while this anchor holds focus.

Accessibility

When href is set, the entire card is wrapped in a link, so supply ariaLabel with a descriptive name. Inner interactive elements remain clickable above the overlay via z-index.