CardCard is a flexible container component.

Card - 图1

Documentation

Import

  1. import {CardModule} from 'primeng/card';
  2.  

Getting Started

Card is defined with p-card element.

  1. <p-card>
  2. Content
  3. </p-card>
  4.  

Header

Header text of the card is provided using the header property, optionally subheader property is available for additional information about the card.

  1. <p-card header="header">
  2. Content
  3. </p-card>
  4.  

Header and Footers sections can be customized using p-header and p-footer components.

  1. <p-card>
  2. <p-header>
  3. Header content here
  4. </p-header>
  5. Body Content
  6. <p-footer>
  7. Footer content here
  8. </p-footer>
  9. </p-card>
  10.  

Properties

NameTypeDefaultDescription
headerstringnullTitle of the card.
subheaderstringnullSecondary title of the card.
stylestringnullInline style of the component.
styleClassstringnullStyle class of the component.

Styling

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
ui-cardContainer element.
ui-card-headerTitle element.
ui-card-subheaderSubtitle element.
ui-card-contentContent of the card.
ui-card-footerFooter of the card.

Dependencies

None.

Source

View on GitHub

  1. <p-card header="Simple Card" [style]="{width: '360px'}">
  2. <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt
  3. quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!</div>
  4. </p-card>
  5. <br>
  6. <br>
  7. <p-card header="Advanced Card" subheader="Subheader" [style]="{width: '360px'}" styleClass="ui-card-shadow">
  8. <p-header>
  9. <img src="Card" src="assets/showcase/images/usercard.png">
  10. </p-header>
  11. <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt
  12. quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!</div>
  13. <p-footer>
  14. <button pButton type="button" label="Save" icon="pi pi-check" style="margin-right: .25em"></button>
  15. <button pButton type="button" label="Cancel" icon="pi pi-times" class="ui-button-secondary"></button>
  16. </p-footer>
  17. </p-card>
  18.