Introducing PrimeReact v11-alpha 🎉Discover Now

Card

An unstyled, flexible container component with compound composition.

Build fully custom content containers with complete control over layout and styling.

Pro Subscription
Everything you need to scale your workflow

Get unlimited access to all features, priority support, and advanced analytics to help your team grow faster.

basic-demo

Pre-styled Versions

Choose a pre-styled library to use Card with ready-made designs.
For hook-based usage without components, see the Headless API.

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 Root to 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.

Loading...
/* Select a part to see its CSS selector for custom styling */

API#

CardRoot#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: CardRootInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: CardRootInstance) => string)
The class name to apply to the component.
asstring | 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.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceCardRootInstance
The instance to pass to the component.
ptSafeRecord<CardRootPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: CardRootInstance) => ReactNode
The render function to render the component with instance access.
childrenany
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.
AttributeValue
data-scopecard
data-partroot

Defines passthrough(pt) options of Card component.

labeltypedescription
rootCardRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
bodyCardRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the body's DOM element.
headerCardRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the header's DOM element.
titleCardRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the title's DOM element.
subtitleCardRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the subtitle's DOM element.
captionCardRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the caption's DOM element.
contentCardRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the content's DOM element.
footerCardRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the footer's DOM element.

CardHeader#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: CardHeaderInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: CardHeaderInstance) => string)
The class name to apply to the component.
asReactNode
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceCardHeaderInstance
The instance to pass to the component.
ptSafeRecord<CardHeaderPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: CardHeaderInstance) => ReactNode
The render function to render the component with instance access.
childrenany
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.

labeltypedescription
rootCardHeaderPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

CardBody#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: CardBodyInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: CardBodyInstance) => string)
The class name to apply to the component.
asReactNode
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceCardBodyInstance
The instance to pass to the component.
ptSafeRecord<CardBodyPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: CardBodyInstance) => ReactNode
The render function to render the component with instance access.
childrenany
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.

labeltypedescription
rootCardBodyPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

CardCaption#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: CardCaptionInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: CardCaptionInstance) => string)
The class name to apply to the component.
asReactNode
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceCardCaptionInstance
The instance to pass to the component.
ptSafeRecord<CardCaptionPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: CardCaptionInstance) => ReactNode
The render function to render the component with instance access.
childrenany
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.

labeltypedescription
rootCardCaptionPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

CardTitle#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: CardTitleInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: CardTitleInstance) => string)
The class name to apply to the component.
asReactNode
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceCardTitleInstance
The instance to pass to the component.
ptSafeRecord<CardTitlePassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: CardTitleInstance) => ReactNode
The render function to render the component with instance access.
childrenany
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.

labeltypedescription
rootCardTitlePassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

CardSubtitle#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: CardSubtitleInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: CardSubtitleInstance) => string)
The class name to apply to the component.
asReactNode
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceCardSubtitleInstance
The instance to pass to the component.
ptSafeRecord<CardSubtitlePassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: CardSubtitleInstance) => ReactNode
The render function to render the component with instance access.
childrenany
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.

labeltypedescription
rootCardSubtitlePassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

CardContent#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: CardContentInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: CardContentInstance) => string)
The class name to apply to the component.
asReactNode
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceCardContentInstance
The instance to pass to the component.
ptSafeRecord<CardContentPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: CardContentInstance) => ReactNode
The render function to render the component with instance access.
childrenany
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.

labeltypedescription
rootCardContentPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

CardFooter#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: CardFooterInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: CardFooterInstance) => string)
The class name to apply to the component.
asReactNode
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceCardFooterInstance
The instance to pass to the component.
ptSafeRecord<CardFooterPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: CardFooterInstance) => ReactNode
The render function to render the component with instance access.
childrenany
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.

labeltypedescription
rootCardFooterPassThroughType<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).