Skip to main content

ActionCard

The ActionCard is an interactive card component where the entire surface acts as a single hit area. It is reachable via Tab key and triggerable via Enter/Space. It should not contain nested interactive elements.

Import

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

Code

<DhlActionCard
dataAriaLabel="Action card"
onCardClick={() => console.log('clicked')}
>
<DhlText slot="header">Card Header</DhlText>
<DhlText>Card content goes here.</DhlText>
</DhlActionCard>

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-action-card-${getRandomString()}`
dataRoledata-roleAn optional prop defining the semantic role of the card. Use "link" when the card navigates to another page, "button" when it triggers an action."button" | "link"DHL_ACTION_CARD.ROLE.BUTTON
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
hrefhrefAn optional href prop. When provided, the card acts as a link. This automatically sets the role to "link".stringundefined
isDisabledis-disabledAn optional flag to define if the component is disabled.booleanfalse
targettargetAn optional target prop for the link. Only applicable when href is provided.stringundefined
textAligntext-alignAn optional prop to set the text alignment of the card content."center" | "left"DHL_ACTION_CARD.TEXT_ALIGN.LEFT

Events

EventDescriptionType
cardClickFires when the card is clicked.CustomEvent<MouseEvent>

Slots

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

Dependencies

Depends on

Graph


Built by DHL User Interface Library Team!