Card
Cards with cover, metadata, grid, tabs, loading and actions.
When to use
Card combines information about one object: a project, product or participant. The title, cover and actions help to separate the object from its neighbors. To align multiple cards, use Row/Col or CSS grid; Card itself does not define responsive page columns.
Card CSS Prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. Grid and Meta without prefixCls inherit the Card owner. An explicit empty string in the child selects the ConfigProvider. Nested Input, Typography and Tabs have their own prefixes.
Card parts and composition
title sets the title, extra — the adjacent action, cover — the cover, children — the body, actions — the bottom list of actions. Text areas and complex blocks accept Svelte snippets. CardMeta combines avatar, title and description.
| Problem | Opportunity | Example |
|---|---|---|
| Header and main content | title, extra, children |
Main card |
| Remove outer frame | variant="borderless" |
Without border |
| Add an image and description | cover, CardMeta |
Cover |
| Place cards in columns | Row, Col |
Adaptive mesh |
| Divide the card into cells | CardGrid |
Inner mesh |
| Switch body sections | tabList, bind:activeTabKey |
Tabs |
size sets the normal or small size. Type:inner styles a nested subsection. hoverable adds visual feedback, but doesn't turn the entire div into a button: the action still needs to have an accessible control and a clear label.
Loading, grid and tabs
loading replaces the body with Skeleton. The body's child components are unmounted, so their local state can be reset. Keep important data above Card; Leave the boot control button accessible outside the body being replaced. The title is saved.
Card detects immediate CardGrid after mount. For the same grid geometry for SSR and hydration, set containGrid explicitly. Nested custom wrappers are not recognized as direct CardGrids. This grid does not replace adaptive Row/Col.
tabList describes the headings, and the contents of the selected tab are displayed by the application. defaultActiveTabKey is read for the initial selection, bind:activeTabKey and onTabChange synchronize the state. tabProps allows you to pass supported Tabs settings; keep the keys stable.
Theme and accessibility
variant selects outlined/borderless. ConfigProvider.card specifies general Card settings, ConfigProvider.cardMeta specifies independent Meta settings. A nested record only replaces its entire parent record.
classNames/styles configure the semantic parts. At the root, the order of layers is: provider semantic, provider style, local semantic, local style. styles accepts CSS strings and objects. Card design tokens control the height and background of the header, body padding, and the design of actions.
Card does not guarantee that the string title will become the title of the desired document level. If necessary, pass h2/h3 to the snippet. For actions icons, use native buttons with accessible names; set the cover to a suitable alt.
Examples
Card contents.
One more line.
Card contents.
One more line.
The small size reduces the heading and padding.
Card and dimensions
Title, content and extra; regular and small sizes.
<script lang="ts">
import { Card, Flex } from '@woodger/antd';
</script>
{#snippet extra()}<a
href={("#card-basic-details")}
>{("More details")}</a>{/snippet}
<Flex vertical gap={16}>
<Card
title={("Regular card")}
extra={(extra)}
style="
width: 320px;
max-width: 100%;
"
><p>{("Card contents.")}</p><p>{("One more line.")}</p></Card>
<Card
title={("Small card")}
extra={(extra)}
size="small"
style="
width: 320px;
max-width: 100%;
"
><p>{("Card contents.")}</p><p>{("One more line.")}</p></Card>
</Flex>
<p
id="card-basic-details"
>{("The small size reduces the heading and padding.")}</p>
Without frame
variant="borderless" on a contrasting backing.
<script lang="ts">
import { Card } from '@woodger/antd';
</script>
<style>
.surface {
padding: 24px;
background: var(--ant-color-fill-alter);
border-radius: 8px;
}
</style>
<div
class="surface"
><Card
title={("Without frame")}
variant="borderless"
style="
width: 320px;
max-width: 100%;
"
>{("Card contents.")}</Card></div>
Content without title.
Description of one topic.
Final line.
Contents only
The card can do without a title and extra area.
<script lang="ts">
import { Card } from '@woodger/antd';
</script>
<Card
style="
width: 320px;
max-width: 100%;
"
><p>
{("Content without title.")}
</p><p>
{("Description of one topic.")}
</p><p>
{("Final line.")}
</p></Card>
Cover and description
cover Snippet and CardMeta for title and explanation; hoverable adds visual feedback.
<script lang="ts">
import { Card, CardMeta } from '@woodger/antd';
</script>
{#snippet cover()}<svg
viewBox="0 0 320 160"
role="img"
aria-label={("Mountain landscape")}
style="
display: block;
width: 100%;
height: auto;
"
><rect
width="320"
height="160"
fill="#ccebdc"
/><circle
cx="252"
cy="40"
r="22"
fill="#f5c36b"
/><path
d="M0 160L100 36l86 124z"
fill="#23734a"
/><path
d="M114 160l84-94 122 94z"
fill="#38996a"
/></svg>{/snippet}
<Card hoverable {cover} style="
width: 320px;
max-width: 100%;
">
<CardMeta title={("Mountain route")} description={("Weekend outing")} />
</Card>
Cards in columns
Row and Col form an adaptive grid: one, two or three columns.
<script lang="ts">
import { Card, Col, Row } from '@woodger/antd';
</script>
<style>
.surface {
padding: 16px;
background: var(--ant-color-fill-alter);
border-radius: 8px;
}
</style>
<div class="surface">
<Row gutter={[16, 16]}>
{#each ["Planning", "Development", "Check"] as title}
<Col xs={24} sm={12} lg={8}>
<Card title={(title)} variant="borderless">
{("Description of the project stage.")}
</Card>
</Col>
{/each}
</Row>
</div>
Loading content
Switch replaces the body with a Skeleton; the title remains available.
<script lang="ts">
import { Avatar, Card, CardMeta, Flex, Switch } from '@woodger/antd';
let loading = $state(true);
</script>
{#snippet avatar()}<Avatar
alt={("Anna Novikova")}
>{("AN")}</Avatar>{/snippet}
<Flex vertical gap={16}>
<div><Switch bind:checked={loading} aria-label={("Loading card")} /></div>
<Card
title={("Member profile")}
{loading}
style="
width: 360px;
max-width: 100%;
"
><CardMeta
{avatar}
title={("Anna Novikova")}
description={("Interface developer")}
/></Card>
</Flex>
CardGrid
Equal cells inside Card; containGrid fixes the geometry already on SSR.
<script lang="ts">
import { Card, CardGrid } from '@woodger/antd';
</script>
<style>
.grid :global(.ant-card-grid) {
width: 25%;
text-align: center;
}
@media (max-width:600px) { .grid :global(.ant-card-grid) { width:50%; } }
</style>
<div class="grid"><Card title={("Areas of work")} containGrid>
{#each ["Plans", "Layouts", "Code", "Tests", "Documents", "Issue"] as title, index}
<CardGrid hoverable={index !== 5}>{(title)}</CardGrid>
{/each}
</Card></div>
Description and related information.
Nested cards
type="inner" separates subsections within a general card.
<script lang="ts">
import { Card } from '@woodger/antd';
</script>
<Card title={("Project materials")}>
<p>{("Description and related information.")}</p>
<Card title={("Technical specifications")} type="inner">
{("Requirements and restrictions.")}
</Card>
<Card title={("Release plan")} type="inner" style="margin-top:16px">
{("Verification and publication stages.")}
</Card>
</Card>
Project interface components.
Current: overview. Event: —.
Tabs inside Card
bind:activeTabKey stores the current tab. tabProps.direction changes direction inside the card, and tabProps.more.prefixCls sets the More menu prefix.
<script lang="ts">
import { Button, Card, Checkbox, Flex } from '@woodger/antd';
let rtl = $state(false);
let activeTabKey = $state<string | undefined>('overview');
let changed = $state('—');
</script>
{#snippet extra()}
<Button size="small" onclick={() => { activeTabKey = 'overview'; }}>
{("Go to review")}
</Button>
{/snippet}
<Flex vertical gap={16}>
<Checkbox bind:checked={rtl}>{("RTL logical tabs")}</Checkbox>
<Card title={("Project")} extra={(extra)} tabList={[{
key: 'overview',
label: "Overview"
}, { key: 'details', label: "Details" }]} tabProps={{
direction: rtl ? 'rtl' : 'ltr',
more: { prefixCls: 'card-tabs-more', overlayClassName: 'ant-tabs-dropdown' }
}} bind:activeTabKey onTabChange={key => {
changed = key;
}}>
<p>{(activeTabKey === 'details'
? "Svelte 5, TypeScript and public npm package."
: "Project interface components.")}</p>
</Card>
<p
role="status"
aria-label={("Selected Card Tab")}
>{("Current: ")}{activeTabKey}{(". Event: ")}{changed}.</p>
</Flex>
Action not selected
Avatar and actions
CardMeta combines avatar, title and description; actions contains real buttons.
<script lang="ts">
import { Avatar, Button, Card, CardMeta } from '@woodger/antd';
let action = $state(("Action not selected"));
</script>
{#snippet cover()}<svg
viewBox="0 0 320 160"
role="img"
aria-label={("Mountain landscape")}
style="
display: block;
width: 100%;
height: auto;
"
><rect
width="320"
height="160"
fill="#ccebdc"
/><circle
cx="252"
cy="40"
r="22"
fill="#f5c36b"
/><path
d="M0 160L100 36l86 124z"
fill="#23734a"
/><path
d="M114 160l84-94 122 94z"
fill="#38996a"
/></svg>{/snippet}
{#snippet avatar()}<Avatar
alt={("Author: Anna Novikova")}
>{("AN")}</Avatar>{/snippet}
{#snippet settings()}<Button
type="text"
aria-label={("Card settings")}
onclick={() => { action = ("Opened settings"); }}
><svg
viewBox="0 0 24 24"
width="18"
height="18"
fill="none"
stroke="currentColor"
stroke-width="2"
aria-hidden="true"
><circle
cx="12"
cy="12"
r="4"
/><path
d="M12 2v4m0 12v4M2 12h4m12 0h4M5 5l3 3m8 8 3 3M5 19l3-3M16 8l3-3"
/></svg></Button>{/snippet}
{#snippet edit()}<Button
type="text"
aria-label={("Change card")}
onclick={() => { action = ("Editing is open"); }}
><svg
viewBox="0 0 24 24"
width="18"
height="18"
fill="none"
stroke="currentColor"
stroke-width="2"
aria-hidden="true"
><path
d="m16 3 5 5-12 12-6 1 1-6zM13 6l5 5"
/></svg></Button>{/snippet}
{#snippet more()}<Button
type="text"
aria-label={("Card details")}
onclick={() => { action = ("Details open"); }}
><svg
viewBox="0 0 24 24"
width="18"
height="18"
fill="currentColor"
aria-hidden="true"
><circle
cx="4"
cy="12"
r="2"
/><circle
cx="12"
cy="12"
r="2"
/><circle
cx="20"
cy="12"
r="2"
/></svg></Button>{/snippet}
<Card
{cover}
actions={[settings, edit, more]}
style="
width: 420px;
max-width: 100%;
"
><CardMeta
{avatar}
title={("Mountain route")}
description={("Team trip plan")}
/></Card>
<p role="status" aria-label={("Card action")}>{action}</p>
Semantic DOM
Separate design of the Card header and body, avatar and CardMeta description.
<script lang="ts">
import { Avatar, Card, CardMeta } from '@woodger/antd';
</script>
{#snippet avatar()}<Avatar alt={("Anna")}>{("AN")}</Avatar>{/snippet}
<Card title={("Own design")} styles={({ props }) => ({
header: 'background:var(--ant-color-fill-alter)',
title: 'color:#23734a',
body: `padding:${props.size === 'small' ? 12 : 20}px`
})}>
<CardMeta {avatar} title={("Anna Novikova")} description={("Interface developer")} styles={{
avatar: 'padding-inline-end:20px',
title: 'font-weight:700',
description: 'line-height:1.8'
}} />
</Card>
Overall size
Local ConfigProvider sets small size. Own size takes precedence.
<script lang="ts">
import { Card, ConfigProvider, Flex } from '@woodger/antd';
</script>
<ConfigProvider componentSize="small">
<Flex vertical gap={16}>
<Card
title={("Small size from context")}
>{("Compact card.")}</Card>
<Card title={("Explicit regular size")} size="medium">
{("Local component configuration.")}
</Card>
</Flex>
</ConfigProvider>
Card and CardMeta Settings
General semantic defaults, independent records, local styles and nested configuration replacement.
<script lang="ts">
import { Card, CardMeta, Checkbox, ConfigProvider, Input, RadioGroup } from '@woodger/antd';
import type { ComponentSize } from '@woodger/antd';
let green = $state(true);
let size = $state<ComponentSize>('medium');
let draft = $state(("Saved when changing settings"));
const accent = $derived(green ? '#237804' : '#874d00');
</script>
<style>
.settings {
display: grid;
gap: 16px;
margin-bottom: 24px;
}
.examples {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 20px;
padding: 12px;
background: var(--ant-color-fill-quaternary);
}
.draft { margin-top: 16px; }
</style>
<div class="settings">
<Checkbox bind:checked={green}>{("Green Settings Card")}</Checkbox>
<RadioGroup aria-label={("Card size from props")} bind:value={size} options={(['small', 'medium', 'large'])} />
</div>
<ConfigProvider
card={{
variant: 'borderless', class: 'provider-card', style: 'border-radius:8px',
classNames: { root: 'context-card-root' },
styles: ({ props }) => ({
root: 'border-radius:4px',
title: `color:${accent}`,
header: `font-size:${props.size === 'small' ? 16 : 18}px`
})
}}
cardMeta={{ class: 'provider-card-meta', styles: { description: `color:${accent}` } }}>
<div class="examples">
<Card
title={("General settings Card")}
{size}
class="local-card"
style="border-radius:16px"
classNames={{ root: 'local-card-root' }}
styles={{
root: 'border-radius:12px',
body: 'padding:18px'
}}
>
<CardMeta title={("Card description")} description={("CardMeta settings are independent of Card.")}
styles={{ title: 'font-weight:700' }} />
<div
class="draft"
><Input
aria-label={("Card configuration draft")}
bind:value={draft}
/></div>
</Card>
<ConfigProvider card={{ variant: 'outlined' }}>
<Card title={("Replacement card")}>
<CardMeta title={("Meta is inherited")} description={("Frame restored; CardMeta settings are saved.")} />
</Card>
</ConfigProvider>
<ConfigProvider cardMeta={{}}>
<Card title={("Replacement cardMeta")}>
<CardMeta title={("Meta reset")} description={("Card inherits the settings, and CardMeta uses its defaults.")} />
</Card>
</ConfigProvider>
</div>
</ConfigProvider>
Project card
Saved example: tabs, loading state, Avatar and grid.
<script lang="ts">
import { Avatar, Button, Card, CardGrid, CardMeta } from '@woodger/antd';
let loading = $state(false);
let activeTabKey = $state<string | undefined>();
</script>
{#snippet avatar()}<Avatar alt={("Project team")}>AD</Avatar>{/snippet}
{#snippet extra()}<Button size="small" onclick={() => { loading = !loading; }}>{(loading ? "Show" : "Loading")}</Button>{/snippet}
<Card
title={("Project card")}
extra={(extra)}
{loading}
tabList={[{ key: 'overview', label: "Overview" }, { key: 'details', label: "Details" }]}
bind:activeTabKey
>
<CardMeta
{avatar}
title={(activeTabKey === 'details' ? "Svelte 5 and TypeScript" : 'Ant Design Svelte')}
description={("Themes, adaptive grid and standalone components.")}
/>
</Card>
<Card title={("Areas of work")} style="margin-top:16px">
<CardGrid
style="width:50%"
>{("Behavior")}</CardGrid><CardGrid
style="width:50%"
>{("Design")}</CardGrid>
</Card>
Grid and Meta without prefixCls inherit the Card owner. An explicit empty string in the child selects the ConfigProvider. Nested Input, Typography and Tabs have their own prefixes.
CSS prefixes Card
Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.
<script lang="ts">
import { Checkbox, ConfigProvider, Card, CardGrid, CardMeta, Input } from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-card' : '');
let draft = $state(("Draft card"));
</script>
<style>
.example,
.prefix-stage {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("Common prefix Card suite")}</Checkbox>
<Checkbox bind:checked={local}>{("Local prefix Card")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} theme={{ cssVar: { prefix: 'card-theme' } }}>
<div class="prefix-stage">
<Card prefixCls={localPrefix} title={("Project")} styles={{ body: 'padding:0' }}>
<CardGrid style="
width: 100%;
float: none;
">
<CardMeta title={("Documentation")} description={("Grid and Meta inherit the Card prefix")} />
<Input
bind:value={draft}
aria-label={("Draft Card with prefix")}
style="margin-top:12px"
/>
</CardGrid>
</Card>
</div>
</ConfigProvider>
<output aria-label={("CSS prefix Card")}>{("General: ")}{prefix}{("; local: ")}{(localPrefix
|| ("from the provider"))}</output>
<p>
{("Grid and Meta without prefixCls inherit the Card owner. An explicit empty string in the child selects the ConfigProvider. Nested Input, Typography and Tabs have their own prefixes.")}
</p>
</div>
API
Examples are checked against the current ant.design page and the public API of the installed package. Full definitions of Props are in @woodger/antd.
| Theme | Example or limitation |
|---|---|
| Basic card | Header, extra and two sizes. |
| No border | variant=borderless on the substrate. |
| Simple card | Without title. |
| Customized content | Cover and CardMeta. |
| Card in column | Adaptive Grid Row/Col. |
| Loading card | Loading and Skeleton. |
| Grid card | CardGrid and hoverable. |
| Inner card | Nested sections. |
| With tabs | Binding and callback. |
| Support more content configuration | Avatar and actions. |
| Custom semantic dom styling | Card and CardMeta. |
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full CSS prefix of the component and its parts. A non-empty local prop takes precedence; empty string and undefined inherit ConfigProvider. The namespace of the topic is set separately. | string | ConfigProvider.prefixCls + "-card" |
title | Title: text, number or Snippet. | CardContent | — |
extra | Action next to the title. | CardContent | — |
cover | Cover in front of the body. | CardContent | — |
children | Body contents. | Snippet | — |
actions | Actions under the body; Interactive semantics are specified by the application. | readonly CardContent[] | — |
size | small reduces the title and padding. | ComponentSize | context / medium |
variant | Local variant → closest Form.variant → ConfigProvider.card.variant → general ConfigProvider.variant → outlined. outlined/borderless are locally valid; inherited filled/underlined retain the border. | outlined | borderless | From context / outlined |
hoverable | Shadow on hover, without adding click/keyboard behavior. | boolean | false |
loading | Replace the body with Skeleton. | boolean | false |
type | Design of an attached card. | inner | — |
tabList | Tab header elements. | readonly CardTabItem[] | — |
activeTabKey | bind:activeTabKey; the content is displayed by the application. | string | — |
defaultActiveTabKey | Initial value of unmanaged tabs. | string | first tab |
onTabChange | Tab selection event. | (key: string) => void | — |
tabProps | Tabs settings include direction and more.prefixCls. tabList supplies the tabs. | Partial<Omit<TabsProps, "items">> | — |
tabBarExtraContent | Additional tab bar content. | TabsExtraContent | — |
styles | CSS strings and objects for card parts. | CardSemantic<CSSStyle> | — |
classNames | Classes for semantic slots. | CardSlots | callback | — |
containGrid | Explicit mesh geometry for SSR. | boolean | auto after mount |
nativeElement | bind:nativeElement instead of ref. | HTMLDivElement | — |
CardGrid and CardMeta
CardGrid: children, hoverable (default true), class/style. CardMeta: avatar, title, description accept CardContent; styles and classNames design their own semantic slots. Both have bind:nativeElement available.
ConfigProvider.card and cardMeta
CardConfig: variantclassstyleclassNamesstyles.
CardMetaConfig: classstyleclassNamesstyles. class/style - strings, classNames/styles - slots object or function with current props. For Card callback sees the allowed size and variant. The Card and CardMeta settings are independent.
Classes add up. Priority of root styles: defaults.styles.root → defaults.style → local styles.root → local style. For other slots, local values override defaults. A nested card or cardMeta replaces only its entire record; an empty object resets it.
Semantic DOM
Card supports root, header, title, extra, cover, body, actions. CardMeta: root, section, avatar, title, description. CardGrid provides a class/style for the root cell.
Card - container div. hoverable changes the design, but does not turn it into a button. Organize your actions with buttons and links, and pass the headings of the required level to Snippet. The cover should have a meaningful alt or decorative semantics.
Registration tokens
theme.components.Card applies all 13 component tokens: padding, header sizes and background, action styling, extra color, and tab padding. Custom styles and style take precedence over the topic; the overall size is specified via ConfigProvider.componentSize. General colors and typography are inherited from the theme.
| Token | Purpose |
|---|---|
actionsBg | Action area background. |
actionsLiMargin | Indentations of action items. |
bodyPadding | Body indents. |
bodyPaddingSM | Small body indents. |
extraColor | Color extra. |
headerBg | Header background. |
headerFontSize | Title font. |
headerFontSizeSM | Small title font. |
headerHeight | Header height. |
headerHeightSM | Small header height. |
headerPadding | Header indents. |
headerPaddingSM | Small header indents. |
tabsMarginBottom | Bottom indent of tabs. |
| Token | Current value |
|---|---|
colorBgContainer | #ffffff |
colorBorderSecondary | #f0f0f0 |
colorFillAlter | rgba(0,0,0,0.02) |
colorText | rgba(0,0,0,0.88) |
colorTextHeading | rgba(0,0,0,0.88) |
colorTextDescription | rgba(0,0,0,0.45) |
borderRadiusLG | 8 |
fontSize | 14 |
fontSizeLG | 16 |
lineHeight | 1.5714285714285714 |
FAQ
Why does the mesh change after hydration?
Auto-discovery of CardGrid occurs after mount. For stable SSR, set containGrid explicitly and keep the cell structure straight.
Will the local state be preserved during loading?
The body is replaced with Skeleton and unmounted. Keep your important data in a state above the Card.
How to import Card.Grid and Card.Meta?
Use separate CardGrid and CardMeta exports. The content is set by snippets, the design is set by variant and semantic styles.