<cs-card>
StableLayoutSince 0.1

Cards group related content and actions inside a bordered container. Use them to present products, articles, user profiles, or any self-contained unit of information.

A kitten sits patiently between a terracotta pot and decorative grasses. Mittens
This kitten is as cute as he is playful. Bring him home today!
6 weeks old More Info
A kitten between a terracotta pot and decorative grasses. Mittens This kitten is as cute as he is playful. Bring him home today! More Info

Examples

Basic Card

A card can hold any content. Media, a header, and a footer are all optional.

This is just a basic card. No media, no header, and no footer. Just your content.

Headers can be used to display titles and more. If using SSR, you need to also use the has-header attribute to add a header to the card (if not, it is added automatically).

Header Title

This card has a header. You can put all sorts of things in it!

Footers can be used to display actions, summaries, or other relevant content. If using SSR, you need to also use the has-footer attribute to add a footer to the card (if not, it is added automatically).

This card has a footer. You can put all sorts of things in it! Preview

Media

Card media is displayed atop the card and will stretch to fit. If using SSR, you need to also use the has-media attribute to add a media section to the card (if not, it is added automatically).

A kitten walks towards camera on top of pallet.
This card has an image of a kitten walking along a pallet.
This card has a video of a dog wearing shades.

Appearance

Use the appearance attribute to change the card’s visual appearance.

A kitten sits patiently between a terracotta pot and decorative grasses. Outlined (default) A kitten sits patiently between a terracotta pot and decorative grasses. Filled-Outlined A kitten sits patiently between a terracotta pot and decorative grasses. Plain A kitten sits patiently between a terracotta pot and decorative grasses. Filled A kitten sits patiently between a terracotta pot and decorative grasses. Accent

Orientation

Set the orientation attribute to horizontal to create a card with a horizontal, side-by-side layout. Make sure to set a width or maximum width for the media slot. Horizontal cards do not currently contain the header and footer slots.

The actions slot is only available for the horizontal orientation.

A kitten sits patiently between a terracotta pot and decorative grasses. This card has a horizontal orientation with media, body, and actions arranged side-by-side.

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/card/card.js';
import './cornerstone/components/card/card.js';
import CsCard from '@cruglobal/cornerstone-components/react/card/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The card's main content.
actionsAn optional actions section to render at the end for the horizontal card.
footerAn optional footer for the card.
footer-actionsAn optional actions section to render in the footer of the vertical card.
headerAn optional header for the card.
header-actionsAn optional actions section to render in the header of the vertical card.
mediaAn optional media section to render at the start of the card.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
appearanceappearanceThe card's visual appearance.'accent' | 'filled' | 'outlined' | 'filled-outlined' | 'plain''outlined'Yes
hasFooterhas-footerOnly required for SSR. Set to true if you're slotting in a footer element so the server-rendered markup includes the footer before the component hydrates on the client.booleanfalseYes
hasHeaderhas-headerOnly required for SSR. Set to true if you're slotting in a header element so the server-rendered markup includes the header before the component hydrates on the client.booleanfalseYes
hasMediahas-mediaOnly required for SSR. Set to true if you're slotting in a media element so the server-rendered markup includes the media before the component hydrates on the client.booleanfalseYes
orientationorientationRenders the card's orientation *'horizontal' | 'vertical''vertical'Yes
ssrFooterActionsssr-footer-actionsOnly required for SSR. Set to true if you're slotting in a footer-actions element so the server-rendered markup includes the media before the component hydrates on the client.booleanfalseYes
ssrHeaderActionsssr-header-actionsOnly required for SSR. Set to true if you're slotting in a header-actions element so the server-rendered markup includes the media before the component hydrates on the client.booleanfalseYes

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--spacingThe amount of space around and between sections of the card. Expects a single value.var(--cs-space-l)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
actionsThe container that wraps the card's actions.::part(actions)
bodyThe container that wraps the card's main content.::part(body)
footerThe container that wraps the card's footer.::part(footer)
headerThe container that wraps the card's header.::part(header)
mediaThe container that wraps the card's media.::part(media)

SSR

Learn more about Server-Side Rendering (SSR).

If you use the header, media, or footer slots, set the matching has-header, has-media, or has-footer attribute — otherwise only the card's body will render during SSR. This works around the lack of a :has-slotted CSS pseudo-class, which would normally let us style borders based on slotted content.