Card component is a web component that displays a card with the ability to add a title, description, and actions.
Design system docsExamplesDefault Card
The card component is a container component that can contain other components. The card component has a predefined style, but you can customize it with css variables.
Card without any content only displays an empty div with a default background color. As you can see it is not very useful in this state.
The library contains predefined building blocks for the card component. You can use these blocks, or you can use whatever you want to build your card.
Card elements spacing
All the card elements has a predefined spacing, which is basically a margin on the top or the bottom of the element. You can change it with the spacing attribute, which can be none, top, bottom, both.
Also the pure css solution has predefined classes for the spacing. You can use the [card-element-name]-spacing--none, [card-element-name]-spacing--top,
[card-element-name]-spacing--bottom, [card-element-name]-spacing--both classes for the spacing.
Example: dds-card-title-spacing--none.
Card Image
Card image is a simple HTML img tag with a predefined style. It will center and fit the image to the card.
Card title is a simple text component, by default a html span tag. It will display the title with a predefined font size and color. This component automatically inherits the size settings of the parent card.
This can be changed by the parentSized="false" attribute. This text also can be changed to a different HTML tag by the renderAs attribute.
<dap-ds-stack><dap-ds-card><dap-ds-card-imagesrc="/img/components/apples.webp"alt="alma"></dap-ds-card-image><dap-ds-card-titlerenderAs="h2"spacing="both"> Title as H2 </dap-ds-card-title></dap-ds-card>Pure CSS solution:<divclassName="dds-card"><imgclassName="dds-card-image"src="/img/components/apples.webp"alt="alma"/><h2className="dds-card-title dds-card-title--sm dds-card-title-spacing--both"> Title as H2 </h2></div></dap-ds-stack>
Card Subtitle
Card subtitle is very similar to the card title. It is a simple text component, an html span tag.
<dap-ds-stack><dap-ds-card><dap-ds-card-imagesrc="/img/components/apples.webp"alt="alma"></dap-ds-card-image><dap-ds-card-subtitle>Subtitle</dap-ds-card-subtitle><dap-ds-card-titlerenderAs="h2"spacing="bottom"> Title as H2 </dap-ds-card-title></dap-ds-card>Pure CSS solution:<divclassName="dds-card"><imgclassName="dds-card-image"src="/img/components/apples.webp"alt="alma"/><spanclassName="dds-card-subtitle dds-card-subtitle--sm dds-card-subtitle-spacing--top">Subtitle</span><h2className="dds-card-title dds-card-title--sm dds-card-title-spacing--bottom"> Title as H2 </h2></div></dap-ds-stack>
Card Content
Card content is a container component that can contain other components, by default it is an HTML div tag. This component automatically inherits the size settings of the parent card.
This can be changed by the parentSized="false" attribute. This text also can be changed to a different HTML tag by the renderAs attribute.
<dap-ds-stack><dap-ds-card><dap-ds-card-imagesrc="/img/components/apples.webp"alt="alma"></dap-ds-card-image><dap-ds-card-subtitle>Subtitle</dap-ds-card-subtitle><dap-ds-card-titlespacing="none">Title</dap-ds-card-title><dap-ds-card-content> Content</dap-ds-card-content></dap-ds-card>Pure CSS solution:<divclassName="dds-card"><imgclassName="dds-card-image"src="/img/components/apples.webp"alt="alma"/><spanclassName="dds-card-subtitle dds-card-subtitle--sm dds-card-subtitle-spacing--top">Subtitle</span><h2className="dds-card-title dds-card-title--sm dds-card-title-spacing--none"> Title as H2 </h2><spanclassName="dds-card-content dds-card-content--sm dds-card-content-spacing--bottom"> Content</span></div></dap-ds-stack>
Actions
That is what i call a card! We added an image, a title, a subtitle, content. Let's add some actions to it. The card actions component is a container component that can contain other components, like buttons.
The card component can be interactive also. By setting the interactive attribute to true, the card will have a hover effect.
In this way the card will be rendered as an a tag, and you can set the href attribute to navigate to a different page. You can set the target and rel attributes also.
The card component has a predefined size, but you can change it with the size attribute. The size can be sm, lg. By default all the card elements will inherit the size settings of the parent card. This can be changed by the parentSized="false" attribute.
<><dap-ds-cardsize="sm"><dap-ds-card-subtitle>Subtitle sm</dap-ds-card-subtitle><dap-ds-card-title>Title sm</dap-ds-card-title><dap-ds-card-content> Content sm</dap-ds-card-content><dap-ds-card-actions><dap-ds-button>Action 1</dap-ds-button><dap-ds-button>Action 2</dap-ds-button></dap-ds-card-actions></dap-ds-card><dap-ds-cardsize="lg"><dap-ds-card-subtitle>Subtitle lg</dap-ds-card-subtitle><dap-ds-card-title>Title lg</dap-ds-card-title><dap-ds-card-content> Content lg</dap-ds-card-content><dap-ds-card-actions><dap-ds-button>Action 1</dap-ds-button><dap-ds-button>Action 2</dap-ds-button></dap-ds-card-actions></dap-ds-card>/* parentSized="false" on the title */<dap-ds-cardsize="lg"><dap-ds-card-subtitle>Subtitle lg</dap-ds-card-subtitle><dap-ds-card-titleparentSized="false"size="sm">Title sm, parentSized="false"</dap-ds-card-title><dap-ds-card-content> Content lg</dap-ds-card-content><dap-ds-card-actions><dap-ds-button>Action 1</dap-ds-button><dap-ds-button>Action 2</dap-ds-button></dap-ds-card-actions></dap-ds-card></>
Customizing the cardHorizontal card with image on the left side and content on the right side.
HTML
<dap-ds-stack><dap-ds-cardsize="lg"id="horizontal-card-image"><divclassName="row"><dap-ds-card-imageheight="260"width="260"id="horizontal-image"src="/img/components/apples.webp"alt="alma"></dap-ds-card-image><divclassName="column"><dap-ds-card-subtitlespacing="none"> Subtitle </dap-ds-card-subtitle><dap-ds-card-titlerenderAs="h1"spacing="none"> title lg </dap-ds-card-title><dap-ds-card-contentspacing="none"> Content </dap-ds-card-content><dap-ds-card-actions><dap-ds-button>Action 1</dap-ds-button></dap-ds-card-actions></div></div></dap-ds-card>Pure Css solution:<divid="horizontal-card-image"className="dds-card dds-card--lg"><divclassName="row"><imgid="horizontal-image"className="dds-card-image"src="/img/components/apples.webp"style={{width:260, height:260}}alt="alma"/><divclassName="column"><spanclassName="dds-card-subtitle dds-card-subtitle--lg dds-card-subtitle-spacing--none">Subtitle</span><spanclassName="dds-card-title dds-card-title--lg"> title lg </span><spanclassName="dds-card-content dds-card-content--lg dds-card-content-spacing--none"> Large text</span><divclassName="dds-card-actions dds-card-actions--lg card-actions-spacing--bottom"><dap-ds-button>Action 1</dap-ds-button></div></div></div></div></dap-ds-stack>
Card with icon or avatar and horizontal alignment.
HTML
<dap-ds-stack><dap-ds-cardid="simple-card-icon"size="lg"><dap-ds-card-contentid="simple-card-content"spacing="none"><dap-ds-iconid="custom-card-icon"name="checkbox-circle-fill"></dap-ds-icon><span><dap-ds-card-titlespacing="none"> Icon </dap-ds-card-title><dap-ds-typographyvariant="description"> This is an icon with horizontal alignment.</dap-ds-typography></span></dap-ds-card-content></dap-ds-card><dap-ds-cardid="simple-card-icon"size="lg"><dap-ds-card-contentid="simple-card-content"spacing="none"><dap-ds-avatarsize="sm"src="/img/components/apples.webp"></dap-ds-avatar><span><dap-ds-card-titlespacing="none"> Avatar </dap-ds-card-title><dap-ds-typographyvariant="description"> This is an avatar with horizontal alignment.</dap-ds-typography></span></dap-ds-card-content></dap-ds-card><divid="simple-card-icon"className="dds-card dds-card--sm"><spanid="simple-card-content-native"className="dds-card-content dds-card-content--lg dds-card-content-spacing--none"><dap-ds-iconid="custom-card-icon"name="checkbox-circle-fill"></dap-ds-icon><span><spanclassName="dds-card-title dds-card-title--lg dds-card-title-spacing--none"> Icon</span><spanclassName="dds-typography dds-typography-description"> This is an icon with horizontal alignment.</span></span></span></div><divid="simple-card-icon"className="dds-card dds-card--sm"><spanid="simple-card-content-native"className="dds-card-content dds-card-content--lg dds-card-content-spacing--none"><dap-ds-avatarsize="sm"src="/img/components/apples.webp"></dap-ds-avatar><span><spanclassName="dds-card-title dds-card-title--lg dds-card-title-spacing--none"> Icon</span><spanclassName="dds-typography dds-typography-description"> This is an icon with horizontal alignment.</span></span></span></div></dap-ds-stack>
<dap-ds-cardsize="lg"><dap-ds-card-content><dap-ds-avatarstyle={{margin:'var(--dds-spacing-400) 0'}}src="/img/components/apples.webp"size="lg"alt="alma"></dap-ds-avatar><dap-ds-card-titlenoPaddingspacing="none"> Title </dap-ds-card-title> Szoveg</dap-ds-card-content></dap-ds-card>