Card
An unstyled, flexible container component with compound composition.
Build fully custom content containers with complete control over layout and styling.
Get unlimited access to all features, priority support, and advanced analytics to help your team grow faster.
Pre-styled Versions
Features#
- Compound component API with eight sub-components:
Root,Header,Body,Caption,Title,Subtitle,Content,Footer - Flexible content structure — compose sub-components in any combination
- Context sharing from
Rootto all descendant sub-components
Usage#
import { Card } from 'primereact/card';<Card.Root>
<Card.Header />
<Card.Body>
<Card.Caption>
<Card.Title />
<Card.Subtitle />
</Card.Caption>
<Card.Content />
<Card.Footer />
</Card.Body>
</Card.Root>Behavior#
Polymorphic Rendering#
Use as on any sub-component to change the rendered HTML element.
<Card.Root as="article">
<Card.Header as="figure">
<img src="/photo.jpg" alt="Photo" />
</Card.Header>
<Card.Body as="section">
<Card.Title as="h2">Title</Card.Title>
<Card.Content as="main">...</Card.Content>
</Card.Body>
</Card.Root>Default elements: Root=div, Header=div, Body=div, Caption=div, Title=div, Subtitle=div, Content=div, Footer=div.
Render Function Children#
Sub-components accept a render function as children, providing access to the component instance.
<Card.Content>{(instance) => <p>Card ID: {instance.card?.id}</p>}</Card.Content>Pass Through#
Some parts may not be visible in the preview depending on the component's current state.
/* Select a part to see its CSS selector for custom styling */API#
CardRoot#
| Name | Type | Default |
|---|---|---|
ref | Ref<unknown> | — |
| The reference to the component instance. | ||
pIf | boolean | true |
| Whether the component should be rendered. | ||
style | CSSProperties | ((instance?: CardRootInstance) => CSSProperties) | — |
| The style to apply to the component. | ||
className | string | ((instance?: CardRootInstance) => string) | — |
| The class name to apply to the component. | ||
as | string | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode> | — |
| The component type to render. | ||
asChild | boolean | false |
| Whether the component should be rendered as a child component. | ||
instance | CardRootInstance | — |
| The instance to pass to the component. | ||
pt | SafeRecord<CardRootPassThrough> | — |
| The pass-through props to pass to the component. | ||
ptOptions | PassThroughOptions | — |
| The pass-through options to pass to the component. | ||
unstyled | boolean | — |
| Whether the component should be rendered without classes. | ||
dt | unknown | — |
| The design token to use for the component. | ||
styles | StylesOptions<ComponentInstance> | — |
| The styles to use for the component. | ||
render | (instance: CardRootInstance) => ReactNode | — |
| The render function to render the component with instance access. | ||
children | any | — |
| The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates. | ||
[key: string] | any | — |
pt-{optionName}-* | - | — |
| Pass through attributes for customizing component. For more info, see Pass Through tab. | ||
| Attribute | Value |
|---|---|
data-scope | card |
data-part | root |
Defines passthrough(pt) options of Card component.
| label | type | description |
|---|---|---|
| root | CardRootPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the root's DOM element. |
| body | CardRootPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the body's DOM element. |
| header | CardRootPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the header's DOM element. |
| title | CardRootPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the title's DOM element. |
| subtitle | CardRootPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the subtitle's DOM element. |
| caption | CardRootPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the caption's DOM element. |
| content | CardRootPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the content's DOM element. |
| footer | CardRootPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the footer's DOM element. |
CardHeader#
| Name | Type | Default |
|---|---|---|
ref | Ref<unknown> | — |
| The reference to the component instance. | ||
pIf | boolean | true |
| Whether the component should be rendered. | ||
style | CSSProperties | ((instance?: CardHeaderInstance) => CSSProperties) | — |
| The style to apply to the component. | ||
className | string | ((instance?: CardHeaderInstance) => string) | — |
| The class name to apply to the component. | ||
as | ReactNode | — |
| The component type to render. | ||
asChild | boolean | false |
| Whether the component should be rendered as a child component. | ||
instance | CardHeaderInstance | — |
| The instance to pass to the component. | ||
pt | SafeRecord<CardHeaderPassThrough> | — |
| The pass-through props to pass to the component. | ||
ptOptions | PassThroughOptions | — |
| The pass-through options to pass to the component. | ||
unstyled | boolean | — |
| Whether the component should be rendered without classes. | ||
dt | unknown | — |
| The design token to use for the component. | ||
styles | StylesOptions<ComponentInstance> | — |
| The styles to use for the component. | ||
render | (instance: CardHeaderInstance) => ReactNode | — |
| The render function to render the component with instance access. | ||
children | any | — |
| The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates. | ||
pt-{optionName}-* | - | — |
| Pass through attributes for customizing component. For more info, see Pass Through tab. | ||
Defines passthrough(pt) options of CardHeader component.
| label | type | description |
|---|---|---|
| root | CardHeaderPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the root's DOM element. |
CardBody#
| Name | Type | Default |
|---|---|---|
ref | Ref<unknown> | — |
| The reference to the component instance. | ||
pIf | boolean | true |
| Whether the component should be rendered. | ||
style | CSSProperties | ((instance?: CardBodyInstance) => CSSProperties) | — |
| The style to apply to the component. | ||
className | string | ((instance?: CardBodyInstance) => string) | — |
| The class name to apply to the component. | ||
as | ReactNode | — |
| The component type to render. | ||
asChild | boolean | false |
| Whether the component should be rendered as a child component. | ||
instance | CardBodyInstance | — |
| The instance to pass to the component. | ||
pt | SafeRecord<CardBodyPassThrough> | — |
| The pass-through props to pass to the component. | ||
ptOptions | PassThroughOptions | — |
| The pass-through options to pass to the component. | ||
unstyled | boolean | — |
| Whether the component should be rendered without classes. | ||
dt | unknown | — |
| The design token to use for the component. | ||
styles | StylesOptions<ComponentInstance> | — |
| The styles to use for the component. | ||
render | (instance: CardBodyInstance) => ReactNode | — |
| The render function to render the component with instance access. | ||
children | any | — |
| The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates. | ||
pt-{optionName}-* | - | — |
| Pass through attributes for customizing component. For more info, see Pass Through tab. | ||
Defines passthrough(pt) options of CardBody component.
| label | type | description |
|---|---|---|
| root | CardBodyPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the root's DOM element. |
CardCaption#
| Name | Type | Default |
|---|---|---|
ref | Ref<unknown> | — |
| The reference to the component instance. | ||
pIf | boolean | true |
| Whether the component should be rendered. | ||
style | CSSProperties | ((instance?: CardCaptionInstance) => CSSProperties) | — |
| The style to apply to the component. | ||
className | string | ((instance?: CardCaptionInstance) => string) | — |
| The class name to apply to the component. | ||
as | ReactNode | — |
| The component type to render. | ||
asChild | boolean | false |
| Whether the component should be rendered as a child component. | ||
instance | CardCaptionInstance | — |
| The instance to pass to the component. | ||
pt | SafeRecord<CardCaptionPassThrough> | — |
| The pass-through props to pass to the component. | ||
ptOptions | PassThroughOptions | — |
| The pass-through options to pass to the component. | ||
unstyled | boolean | — |
| Whether the component should be rendered without classes. | ||
dt | unknown | — |
| The design token to use for the component. | ||
styles | StylesOptions<ComponentInstance> | — |
| The styles to use for the component. | ||
render | (instance: CardCaptionInstance) => ReactNode | — |
| The render function to render the component with instance access. | ||
children | any | — |
| The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates. | ||
pt-{optionName}-* | - | — |
| Pass through attributes for customizing component. For more info, see Pass Through tab. | ||
Defines passthrough(pt) options of CardCaption component.
| label | type | description |
|---|---|---|
| root | CardCaptionPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the root's DOM element. |
CardTitle#
| Name | Type | Default |
|---|---|---|
ref | Ref<unknown> | — |
| The reference to the component instance. | ||
pIf | boolean | true |
| Whether the component should be rendered. | ||
style | CSSProperties | ((instance?: CardTitleInstance) => CSSProperties) | — |
| The style to apply to the component. | ||
className | string | ((instance?: CardTitleInstance) => string) | — |
| The class name to apply to the component. | ||
as | ReactNode | — |
| The component type to render. | ||
asChild | boolean | false |
| Whether the component should be rendered as a child component. | ||
instance | CardTitleInstance | — |
| The instance to pass to the component. | ||
pt | SafeRecord<CardTitlePassThrough> | — |
| The pass-through props to pass to the component. | ||
ptOptions | PassThroughOptions | — |
| The pass-through options to pass to the component. | ||
unstyled | boolean | — |
| Whether the component should be rendered without classes. | ||
dt | unknown | — |
| The design token to use for the component. | ||
styles | StylesOptions<ComponentInstance> | — |
| The styles to use for the component. | ||
render | (instance: CardTitleInstance) => ReactNode | — |
| The render function to render the component with instance access. | ||
children | any | — |
| The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates. | ||
pt-{optionName}-* | - | — |
| Pass through attributes for customizing component. For more info, see Pass Through tab. | ||
Defines passthrough(pt) options of CardTitle component.
| label | type | description |
|---|---|---|
| root | CardTitlePassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the root's DOM element. |
CardSubtitle#
| Name | Type | Default |
|---|---|---|
ref | Ref<unknown> | — |
| The reference to the component instance. | ||
pIf | boolean | true |
| Whether the component should be rendered. | ||
style | CSSProperties | ((instance?: CardSubtitleInstance) => CSSProperties) | — |
| The style to apply to the component. | ||
className | string | ((instance?: CardSubtitleInstance) => string) | — |
| The class name to apply to the component. | ||
as | ReactNode | — |
| The component type to render. | ||
asChild | boolean | false |
| Whether the component should be rendered as a child component. | ||
instance | CardSubtitleInstance | — |
| The instance to pass to the component. | ||
pt | SafeRecord<CardSubtitlePassThrough> | — |
| The pass-through props to pass to the component. | ||
ptOptions | PassThroughOptions | — |
| The pass-through options to pass to the component. | ||
unstyled | boolean | — |
| Whether the component should be rendered without classes. | ||
dt | unknown | — |
| The design token to use for the component. | ||
styles | StylesOptions<ComponentInstance> | — |
| The styles to use for the component. | ||
render | (instance: CardSubtitleInstance) => ReactNode | — |
| The render function to render the component with instance access. | ||
children | any | — |
| The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates. | ||
pt-{optionName}-* | - | — |
| Pass through attributes for customizing component. For more info, see Pass Through tab. | ||
Defines passthrough(pt) options of CardSubtitle component.
| label | type | description |
|---|---|---|
| root | CardSubtitlePassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the root's DOM element. |
CardContent#
| Name | Type | Default |
|---|---|---|
ref | Ref<unknown> | — |
| The reference to the component instance. | ||
pIf | boolean | true |
| Whether the component should be rendered. | ||
style | CSSProperties | ((instance?: CardContentInstance) => CSSProperties) | — |
| The style to apply to the component. | ||
className | string | ((instance?: CardContentInstance) => string) | — |
| The class name to apply to the component. | ||
as | ReactNode | — |
| The component type to render. | ||
asChild | boolean | false |
| Whether the component should be rendered as a child component. | ||
instance | CardContentInstance | — |
| The instance to pass to the component. | ||
pt | SafeRecord<CardContentPassThrough> | — |
| The pass-through props to pass to the component. | ||
ptOptions | PassThroughOptions | — |
| The pass-through options to pass to the component. | ||
unstyled | boolean | — |
| Whether the component should be rendered without classes. | ||
dt | unknown | — |
| The design token to use for the component. | ||
styles | StylesOptions<ComponentInstance> | — |
| The styles to use for the component. | ||
render | (instance: CardContentInstance) => ReactNode | — |
| The render function to render the component with instance access. | ||
children | any | — |
| The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates. | ||
pt-{optionName}-* | - | — |
| Pass through attributes for customizing component. For more info, see Pass Through tab. | ||
Defines passthrough(pt) options of CardContent component.
| label | type | description |
|---|---|---|
| root | CardContentPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the root's DOM element. |
CardFooter#
| Name | Type | Default |
|---|---|---|
ref | Ref<unknown> | — |
| The reference to the component instance. | ||
pIf | boolean | true |
| Whether the component should be rendered. | ||
style | CSSProperties | ((instance?: CardFooterInstance) => CSSProperties) | — |
| The style to apply to the component. | ||
className | string | ((instance?: CardFooterInstance) => string) | — |
| The class name to apply to the component. | ||
as | ReactNode | — |
| The component type to render. | ||
asChild | boolean | false |
| Whether the component should be rendered as a child component. | ||
instance | CardFooterInstance | — |
| The instance to pass to the component. | ||
pt | SafeRecord<CardFooterPassThrough> | — |
| The pass-through props to pass to the component. | ||
ptOptions | PassThroughOptions | — |
| The pass-through options to pass to the component. | ||
unstyled | boolean | — |
| Whether the component should be rendered without classes. | ||
dt | unknown | — |
| The design token to use for the component. | ||
styles | StylesOptions<ComponentInstance> | — |
| The styles to use for the component. | ||
render | (instance: CardFooterInstance) => ReactNode | — |
| The render function to render the component with instance access. | ||
children | any | — |
| The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates. | ||
pt-{optionName}-* | - | — |
| Pass through attributes for customizing component. For more info, see Pass Through tab. | ||
Defines passthrough(pt) options of CardFooter component.
| label | type | description |
|---|---|---|
| root | CardFooterPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the root's DOM element. |
Accessibility#
Screen Reader#
Card is a structural container with no implicit ARIA role. If the card represents a standalone content region, apply role="region" and provide an accessible name using aria-label or aria-labelledby on Card.Root.
Keyboard Support#
Card does not include built-in keyboard interaction. Keyboard behavior depends on interactive elements placed inside the card (buttons, links, form controls).