A Card is a component to group information or content of a particular subject in one place.
Component variations
Code examples
Here you will find the most common ways of using the Card component.
onClick
With It’s possible to call an action when the user clicks on the Card. To do that, you only need to pass a function to the onClick
prop.
Selectable cards
Sometimes you will need to use the Card as an selectable element in the UI. To achieve that behaviour,
you should use a combination of the onClick
and selected
props. The former controlling the latter.
link
and target
With A Card can be used with the purpose to navigate a user to an external page. To do that a user must pass a value to the href
prop.
Optionally, the user can pass a target
prop to control how the link should be open.
Props
- Name
actions
DescriptionAn array of Menu elements used to render an actions menu
ReactNodeArray - Name
actionsButtonProps
DescriptionProps to pass to the action menu button
Partial<ButtonProps<"button">> - Name
ariaLabel
DescriptionIf the card is selectable and has no title, it will need a aria-label to help screen readers identify it
string - Name
as
DescriptionHandle tag for Card component
HTML Tag or React Component (e.g. div, span, etc) - Name
badge
DescriptionBadge component to show in Card header
ReactElement<any, string | JSXElementConstructor<any>> - Name
children
DescriptionChild nodes to be rendered in the component
ReactNode - Name
className
DescriptionCSS class to be appended to the root element
string - Name
dragHandleRender
DescriptionCustom drag handle renderer. Useful, when integrating cards with drag-n-drop libraries
(props: { isDragging?: boolean; drag: ReactElement<any, string | JSXElementConstructor<any>>; }) => ReactElement<any, string | JSXElementConstructor<any>> - Name
href
DescriptionPassing href into the Card. You need to also add property as="a" to make it rendered as <a />
string - Name
icon
DescriptionIcon to show in the Card header
ReactElement<any, string | JSXElementConstructor<any>> - Name
isDragging
DescriptionApplies dragging styles to the card and drag handle
falsetrue - Name
isHovered
DescriptionApplies hover styles to the card
falsetrue - Name
isLoading
DescriptionLoading state for the component - when true will display loading feedback to the user
falsetrue - Name
isSelected
DescriptionApplies selected styles to the element
falsetrue - Name
margin
Descriptionsets margin to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
marginBottom
Descriptionsets margin-bottom to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
marginLeft
Descriptionsets margin-left to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
marginRight
Descriptionsets margin-right to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
marginTop
Descriptionsets margin-top to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
onClick
DescriptionClick event handler
MouseEventHandler<HTMLElement> - Name
padding
DescriptionPadding size to apply to the component
"none""default""large" - Name
testId
DescriptionA [data-test-id] attribute used for testing purposes
string - Name
title
DescriptionThe title of the entry. It will also be used as aria-label
string