For uniform lists of rows use CdsList, for collapsible sections use CdsExpandablePanel, and when you only need a surface without any structure, use CdsSurface.
Anatomy
A card is assembled from ready-made blocks. The first diagram shows the frame: header, divider, text and the actions bar. The second one shows how the CdsCardItem header works: the prepend and append areas at the edges, the title and the subtitle in the middle. Every block is available as a prop, as a slot and as a separate component.
Variations
Content
There are three ways to fill a card: the title, subtitle and text props for typical cases; the slots of the same name when you need your own markup instead of a string; the CdsCardItem, CdsCardTitle, CdsCardSubtitle and CdsCardText components when you need full control over the structure. The divider prop adds a divider between the header and the text.
| Slot | Description |
|---|---|
title / subtitle / text | Replace the props of the same name |
prepend / append | Content at the edges of the header; replace *-icon and *-avatar |
item | Extra header content below the title |
default | Arbitrary card content |
image | Background image; replaces image |
actions | Actions bar — rendered inside CdsCardActions |
loader | Your own loading indicator while loading is on |
Header
The prepend-icon and append-icon props put an icon at the edges of the header, prepend-avatar and append-avatar put an avatar by image URL. By default the prepend and append areas are pinned to the top of the header; item-align="center" centers them against the title and the subtitle (on CdsCardItem this prop is called align).
Appearance
A clickable card — one with a link, a click handler, inside a group or with the link prop — highlights its border on hover by itself, you do not need to turn anything on. borderless removes the border — for cards on a surface or inside other containers.
Link
Pass href (or to with a vue-router route) and the card is rendered as an a tag and becomes clickable as a whole, keeping its appearance.
Images
An image at the top is a CdsImage component placed first inside the card. You can overlay content on top of it by putting the header into the image slot.
The image prop stretches the image as the background of the whole card. Take care of the contrast: set the text color through color and pick a dark image or a gradient.
Group with selection
Wrap the cards in CdsCardGroup and give each of them a value — the group turns into a selection control with v-model, and the selected card gets a highlighted border. required forbids clearing the selection.
The multiple prop enables multiple selection — v-model then holds an array of values.
Guidelines
Scenarios
Choosing a plan
A group of cards replaces radio buttons when every option needs room for a price and a description. The check-fill icon in append-icon repeats the selection in the header, and the button below stays disabled until an option is picked.
Product cards
A storefront is assembled from ready-made blocks: CdsImage with the photo, a rating made of icons in CdsCardText, CdsTag tags with the specs and a pair of actions in CdsCardActions — the main "add to cart" button and a secondary icon button for favorites that toggles the bookmark and tints it with a utility class. The loading and disabled props show the loading bar and protect the card from repeated clicks while the request runs — press «В корзину».
Expandable details
Hide secondary content behind an expander: a block with v-if is wrapped in CdsTransitionExpand for a smooth animation. Anything can trigger the expansion — a chevron icon or a button in the actions bar.
Gallery
Cards nest into each other: the outer one is an album with a header and a counter, the inner ones are photo tiles in a mosaic built on a CSS grid with a fixed row height; col-span / row-span make individual shots larger. The absolute mode of CdsImage stretches the photo across the whole tile, borderless removes the borders, and a gradient darkens the last tile under the counter of the remaining photos.
API
CdsCard
Props
| Name | Type | Default | Description |
|---|---|---|---|
activeColor | string | undefined | — | Color of the component in its active state |
appendAvatar | string | undefined | — | Avatar shown after (to the right of) the content in the card header. |
appendIcon | IconValue | undefined | — | Icon shown after (to the right of) the content in the card header. |
baseColor | string | undefined | — | Color of the component in its inactive state |
bgColor | string | undefined | — | Background color of the component |
borderless | boolean | undefined | — | Removes the border of the card |
color | string | undefined | — | Component color |
content | string | number | undefined | — | Content displayed in the component. |
disabled | boolean | null | undefined | null | Disabled state |
divider | boolean | undefined | — | Adds a divider between the header and the content |
exact | boolean | undefined | — | If true, the active state applies only on an exact route match |
height | string | number | undefined | — | Component height |
href | string | undefined | — | The href attribute of the link. When set, the component behaves as a regular link |
image | string | undefined | — | URL of the background image of the card. |
itemAlign | "start" | "end" | "center" | undefined | — | Alignment of the prepend / append areas against the header content. Passed to CdsCardItem as align. |
link | boolean | undefined | — | Gives the card the styles and the behavior of a link. |
loading | string | boolean | undefined | — | Loading indicator for the component |
location | Anchor | null | undefined | — | Position of the element relative to its container, for example "top left", "center", "bottom right". |
maxHeight | string | number | undefined | — | Maximum component height |
maxWidth | string | number | undefined | — | Maximum component width |
minHeight | string | number | undefined | — | Minimum component height |
minWidth | string | number | undefined | — | Minimum component width |
position | "absolute" | "static" | "fixed" | "relative" | "sticky" | undefined | — | CSS positioning of the component — the value of the position property |
prependAvatar | string | undefined | — | Avatar shown before (to the left of) the content in the card header. |
prependIcon | IconValue | undefined | — | Icon shown before (to the left of) the content in the card header. |
replace | boolean | undefined | — | If true, navigation replaces the current history entry instead of pushing a new one |
selectedClass | string | undefined | — | CSS class applied in the selected state |
subtitle | string | number | boolean | undefined | — | Card subtitle. Rendered inside CdsCardItem below the title. |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
text | string | number | undefined | — | Text displayed in the component. |
textColor | string | undefined | — | Text color of the component |
theme | string | undefined | — | Component theme |
title | string | number | boolean | undefined | — | Card title. Rendered inside CdsCardItem above the subtitle. |
to | LinkTo | undefined | — | Target route or route location object for RouterLink. When set, the component behaves as a RouterLink |
value | any | — | Value of the component within the group |
width | string | number | undefined | — | Component width |
Slots
| Name | Type | Description |
|---|---|---|
actions | any | Actions bar of the card |
append | any | Content after the main content (in place of the append icon or avatar) |
default | any | Default content inside the card |
image | any | Background image of the card |
item | any | Custom rendering of the card item (CdsCardItem) |
loader | LoaderSlotProps | Slot for a custom loading indicator, shown while the loading prop is true. |
prepend | any | Content before the main content (in place of the prepend icon or avatar) |
subtitle | any | Subtitle content |
text | any | Main text content of the card |
title | any | Title content |
CdsCardActions
Props
| Name | Type | Default | Description |
|---|---|---|---|
align | "start" | "end" | "center" | undefined | 'start' | Horizontal alignment of the action buttons |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Card actions, usually buttons |
CdsCardDivider
Props
| Name | Type | Default | Description |
|---|---|---|---|
color | string | undefined | — | Color of the divider. |
contentOffset | string | number | (string | number)[] | undefined | — | Increases the spacing between the content and the lines. When passed as an array, the second value shifts the slot content down (or right when vertical = true). |
gradient | boolean | undefined | — | Adds a fade-out effect on both ends. |
inset | boolean | undefined | — | Adds an indent to horizontal dividers and reduces the maximum height of vertical ones. |
length | string | number | undefined | — | Length of the divider. Defaults to pixels. |
opacity | string | number | undefined | — | Opacity of the divider. |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
theme | string | undefined | — | Component theme |
thickness | string | number | undefined | — | Thickness of the divider. Defaults to pixels. |
variant | "solid" | "dotted" | "dashed" | "double" | undefined | 'solid' | Visual variant of the divider |
vertical | boolean | undefined | — | Renders the divider vertically |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Content of the card divider |
CdsCardGroup
Props
| Name | Type | Default | Description |
|---|---|---|---|
direction | "horizontal" | "vertical" | undefined | 'horizontal' | Switches the component between horizontal and vertical layout. |
disabled | boolean | null | undefined | null | Disabled state |
mandatory | boolean | "force" | undefined | — | Requires at least one item to stay selected |
max | number | undefined | — | Maximum number of items that can be selected |
modelValue | any | — | Value of the selected items of the group |
multiple | boolean | undefined | — | Allows selecting several items at once |
required | boolean | "force" | undefined | — | Requires at least one item to stay selected |
selectedClass | string | undefined | 'cds-card--selected' | CSS class applied in the selected state |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
theme | string | undefined | — | Component theme |
Slots
| Name | Type | Description |
|---|---|---|
default | GroupProvide | Cards of the group. The slot props expose the group state (selection, navigation). |
Exposed
| Name | Type | Description |
|---|---|---|
isSelected | (id: string) => boolean | Checks whether a card with the given id is selected |
next | () => void | Selects the next card |
prev | () => void | Selects the previous card |
select | (id: string, value: boolean) => void | Selects a card by its id |
selected | readonly string[] | Identifiers of the selected cards |
CdsCardItem
Props
| Name | Type | Default | Description |
|---|---|---|---|
align | "start" | "end" | "center" | undefined | — | Alignment of the prepend / append areas against the content. |
appendAvatar | string | undefined | — | Avatar shown after (to the right of) the content. |
appendIcon | IconValue | undefined | — | Icon shown after (to the right of) the content. |
prependAvatar | string | undefined | — | Avatar shown before (to the left of) the content. |
prependIcon | IconValue | undefined | — | Icon shown before (to the left of) the content. |
subtitle | string | number | boolean | undefined | — | Subtitle of the card item. |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
title | string | number | boolean | undefined | — | Title of the card item. |
Slots
| Name | Type | Description |
|---|---|---|
append | any | Content after the main content (in place of the append icon or avatar) |
default | any | Default content inside the body of the card item |
prepend | any | Content before the main content (in place of the prepend icon or avatar) |
subtitle | any | Subtitle content |
title | any | Title content |
CdsCardSubtitle
Props
| Name | Type | Default | Description |
|---|---|---|---|
opacity | string | number | undefined | — | Opacity of the subtitle text. |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Content of the card subtitle |
CdsCardText
Props
| Name | Type | Default | Description |
|---|---|---|---|
opacity | string | number | undefined | — | Opacity of the card text. |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Text content of the card |
CdsCardTitle
Props
| Name | Type | Default | Description |
|---|---|---|---|
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Content of the card title |