Skip to main content

ContentCard

The ContentCard is a non-interactive layout container card that can hold interactive elements such as buttons and links. It supports optional primary and secondary action buttons.

Import

// with @dhl-official/react-library:
import { DhlContentCard } from "@dhl-official/react-library"
// with @dhl-official/ui-libraries/react-library:
import { DhlContentCard } from "@dhl-official/ui-libraries/react-library"

Code

<DhlContentCard
primaryActionLabel="Main Action"
secondaryActionLabel="Secondary Action"
>
<DhlText slot="header">Card Header</DhlText>
<DhlText>Card content goes here.</DhlText>
</DhlContentCard>

Interactive Demo

Readme

Properties

PropertyAttributeDescriptionTypeDefault
dataAriaLabeldata-aria-labelAn optional prop defining the text read by the screen reader to represent the component; use this if you need different text to be read from label.stringundefined
dataIddata-idAn optional prop. Gives a valid HTML ID attribute value for the component.string`dhl-content-card-${getRandomString()}`
dataTestiddata-testidAn optional prop. The test id attached to the component as a data-testid attribute.stringundefined
dataTrackingdata-trackingAn optional data tracking prop for the component.stringundefined
primaryActionLabelprimary-action-labelAn optional label for the primary action button. When provided, renders an outline-black button.stringundefined
secondaryActionLabelsecondary-action-labelAn optional label for the secondary action button. When provided, renders a text variant button.stringundefined
showBordershow-borderAn optional prop to show component border.booleantrue
textAligntext-alignAn optional prop to set the text alignment of the card content."center" | "left"DHL_CONTENT_CARD.TEXT_ALIGN.LEFT

Events

EventDescriptionType
primaryActionFires when the primary action button is clicked.CustomEvent<MouseEvent>
secondaryActionFires when the secondary action button is clicked.CustomEvent<MouseEvent>

Slots

SlotDescription
"footer"used for elements intended to be positioned as the DhlContentCard footer
"header"used for elements intended to be positioned as the DhlContentCard header
"image"used to supply image elements for display within the DhlContentCard
"unnamed"unnamed children slot for DhlContentCard content

Dependencies

Depends on

Graph


Built by DHL User Interface Library Team!