Components
Widget Card
The surface for a single chart, list or metric. Set the card's height on Root; the content area fills what the header leaves and can scroll inside it rather than overflowing the card.
Installation
bunx @happlyui/cli@latest add widget-card
Dependencies
Registry dependencies
These are automatically installed when you add this component.
happly-ui-utils
Usage
import * as WidgetCard from "@/components/ui/widget-card"
<WidgetCard.Root className="h-[288px]">
<WidgetCard.Header>
<WidgetCard.Title>Card title</WidgetCard.Title>
</WidgetCard.Header>
<WidgetCard.Content>{chart}</WidgetCard.Content>
</WidgetCard.Root>
Examples
Default
A title and whatever the card holds. The card's height comes from className on Root.
Card title
<WidgetCard.Root className="h-[288px]">
<WidgetCard.Header>
<WidgetCard.Title>Card title</WidgetCard.Title>
</WidgetCard.Header>
<WidgetCard.Content>{chart}</WidgetCard.Content>
</WidgetCard.Root>
With details
Anything placed after the title sits at the end of the header row. Use a neutral stroke xxsmall Button for the Details action.
Card title
<WidgetCard.Header>
<WidgetCard.Title>Card title</WidgetCard.Title>
<Button.Root variant="neutral" mode="stroke" size="xxsmall" onClick={openDetails}>
Details
</Button.Root>
</WidgetCard.Header>
Compact title
KPI cards use a smaller, muted title and a tighter gap. Both are className overrides.
Metric title
<WidgetCard.Root className="gap-1">
<WidgetCard.Header>
<WidgetCard.Title className="text-paragraph-sm text-text-sub-600">Metric title</WidgetCard.Title>
</WidgetCard.Header>
<WidgetCard.Content>...</WidgetCard.Content>
</WidgetCard.Root>
API Reference
WidgetCard.Root
The card surface. Set its height with className; it has none by default.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Height, width and any other overrides |
WidgetCard.Header
The title row. The first child sits at the start, anything after it at the end.
| Prop | Type | Default | Description |
|---|
WidgetCard.Title
The card title, rendered as an h3.
| Prop | Type | Default | Description |
|---|
WidgetCard.Content
Fills the space below the header and can shrink below its content, so a fixed-height card constrains it.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Add overflow-y-auto when the content can outgrow the card |