Card is a flexible container component.
import { CardModule } from 'primeng/card';
A simple Card is created with a header property along with the content as children.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!
<p-card header="Simple Card">
<p class="m-0">
Lorem ipsum dolor sit amet...
</p>
</p-card>
Card content can be customized further with subHeader, header and footer properties.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!
<p-card header="Advanced Card" subheader="Card Subheader" [style]="{ width: '360px' }">
<ng-template pTemplate="header">
<img alt="Card" src="https://primefaces.org/cdn/primeng/images/card-ng.jpg" />
</ng-template>
<p>
Lorem ipsum dolor sit amet...
</p>
<ng-template pTemplate="footer">
<div class="flex gap-3 mt-1">
<p-button label="Cancel" severity="secondary" class="w-full" styleClass="w-full" />
<p-button label="Save" class="w-full" styleClass="w-full" />
</div>
</ng-template>
</p-card>
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-card | Container element. |
p-card-header | Title element. |
p-card-subheader | Subtitle element. |
p-card-content | Content of the card. |
p-card-footer | Footer of the card. |
A card can be utilized in many use cases as a result no role is enforced, in fact a role may not be necessary if the card is used for presentational purposes only. Any valid attribute is passed to the container element so if you require to use one of the landmark roles like region, you may use the role property.
<p-card role="region">
Content
</p-card>
Component does not include any interactive elements.