Ant Design Svelte

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

Regular card

Card contents.

One more line.

Small card

Card contents.

One more line.

The small size reduces the heading and padding.

Card and dimensions

Title, content and extra; regular and small sizes.

Without frame
Card contents.

Without frame

variant="borderless" on a contrasting backing.

Content without title.

Description of one topic.

Final line.

Contents only

The card can do without a title and extra area.

Mountain route
Weekend outing

Cover and description

cover Snippet and CardMeta for title and explanation; hoverable adds visual feedback.

Planning
Description of the project stage.
Development
Description of the project stage.
Check
Description of the project stage.

Cards in columns

Row and Col form an adaptive grid: one, two or three columns.

Member profile
Loading…

Loading content

Switch replaces the body with a Skeleton; the title remains available.

Areas of work
Plans
Layouts
Code
Tests
Documents
Issue

CardGrid

Equal cells inside Card; containGrid fixes the geometry already on SSR.

Project materials

Description and related information.

Technical specifications
Requirements and restrictions.
Release plan
Verification and publication stages.

Nested cards

type="inner" separates subsections within a general card.

Project

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.

Mountain route
Team trip plan

Action not selected

Avatar and actions

CardMeta combines avatar, title and description; actions contains real buttons.

Own design
Anna Novikova
Interface developer

Semantic DOM

Separate design of the Card header and body, avatar and CardMeta description.

Small size from context
Compact card.
Explicit regular size
Local component configuration.

Overall size

Local ConfigProvider sets small size. Own size takes precedence.

General settings Card
Card description
CardMeta settings are independent of Card.
Replacement card
Meta is inherited
Frame restored; CardMeta settings are saved.
Replacement cardMeta
Meta reset
Card inherits the settings, and CardMeta uses its defaults.

Card and CardMeta Settings

General semantic defaults, independent records, local styles and nested configuration replacement.

Project card
Ant Design Svelte
Themes, adaptive grid and standalone components.
Areas of work
Behavior
Design

Project card

Saved example: tabs, loading state, Avatar and grid.

Project
Documentation
Grid and Meta inherit the Card prefix
General: suite; local: project-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.

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.

Topics of official examples
ThemeExample or limitation
Basic cardHeader, extra and two sizes.
No bordervariant=borderless on the substrate.
Simple cardWithout title.
Customized contentCover and CardMeta.
Card in columnAdaptive Grid Row/Col.
Loading cardLoading and Skeleton.
Grid cardCardGrid and hoverable.
Inner cardNested sections.
With tabsBinding and callback.
Support more content configurationAvatar and actions.
Custom semantic dom stylingCard and CardMeta.
Basic parameters Card
PropertyDescriptionTypeDefault
prefixClsFull 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.stringConfigProvider.prefixCls + "-card"
titleTitle: text, number or Snippet.CardContent—
extraAction next to the title.CardContent—
coverCover in front of the body.CardContent—
childrenBody contents.Snippet—
actionsActions under the body; Interactive semantics are specified by the application.readonly CardContent[]—
sizesmall reduces the title and padding.ComponentSizecontext / medium
variantLocal variant → closest Form.variant → ConfigProvider.card.variant → general ConfigProvider.variant → outlined. outlined/borderless are locally valid; inherited filled/underlined retain the border.outlined | borderlessFrom context / outlined
hoverableShadow on hover, without adding click/keyboard behavior.booleanfalse
loadingReplace the body with Skeleton.booleanfalse
typeDesign of an attached card.inner—
tabListTab header elements.readonly CardTabItem[]—
activeTabKeybind:activeTabKey; the content is displayed by the application.string—
defaultActiveTabKeyInitial value of unmanaged tabs.stringfirst tab
onTabChangeTab selection event.(key: string) => void—
tabPropsTabs settings include direction and more.prefixCls. tabList supplies the tabs.Partial<Omit<TabsProps, "items">>—
tabBarExtraContentAdditional tab bar content.TabsExtraContent—
stylesCSS strings and objects for card parts.CardSemantic<CSSStyle>—
classNamesClasses for semantic slots.CardSlots | callback—
containGridExplicit mesh geometry for SSR.booleanauto after mount
nativeElementbind: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.

Component tokens
TokenPurpose
actionsBgAction area background.
actionsLiMarginIndentations of action items.
bodyPaddingBody indents.
bodyPaddingSMSmall body indents.
extraColorColor extra.
headerBgHeader background.
headerFontSizeTitle font.
headerFontSizeSMSmall title font.
headerHeightHeader height.
headerHeightSMSmall header height.
headerPaddingHeader indents.
headerPaddingSMSmall header indents.
tabsMarginBottomBottom indent of tabs.
Common tokens of the current topic
TokenCurrent value
colorBgContainer#ffffff
colorBorderSecondary#f0f0f0
colorFillAlterrgba(0,0,0,0.02)
colorTextrgba(0,0,0,0.88)
colorTextHeadingrgba(0,0,0,0.88)
colorTextDescriptionrgba(0,0,0,0.45)
borderRadiusLG8
fontSize14
fontSizeLG16
lineHeight1.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.