Cards are flexible surfaces used to group information in a small layout. They give small previews of information or provide secondary content in relation to the content it's near. Several cards can be used together to group related information.
This is the default card
This is the lightest card with a border
This is the darker card
This is the darkest card
This is the complement card
This is the accent card
npm install @patternfly/pfe-card
<pfe-card> <h2 slot="pfe-card--header">Card header</h2> <p>This is the pfe-card body.</p> <div slot="pfe-card--footer"> <p>This is the footer</p> </div> </pfe-card>
All slots are optional. If the slot is not defined, the content will be added to the
body region of the card.
If this slot is used, we expect a heading level tag (h1, h2, h3, h4, h5, h6). An icon, svg, or use of the icon component are also valid in this region.
Default slot (body)
Any content that is not designated for the
footer slot, will go to this slot.
Use this slot for anything that you want to be stuck to the base of the card. This region is bottom-aligned.
There are several attributes available for customizing the visual treatment of this container.
Options include darkest, darker, accent, complement, lighter, lightest. The card has a default value of
#dfdfdf. Your theme will influence these colors so check there first if you are seeing inconsistencies.
Optional background image applied to the entire card container. Alignment of this image can be managed using the
--pfe-card--BackgroundPosition variable which is set to
center center by default.
Optionally adjusts the padding on the container. Accepts:
Optionally allows an image or element to overflow the padding on the container. This property should be added to the direct child of the slotm such as on an image tag; should be added to the element that you want to overflow the container. Accepts:
Optionally apply a border color and weight to the entire card container. The default color and weight is
There are several powerful variables available to hook into and override default styles.
Though using the
color attribute is strongly recommended when setting the background color for the band, you can also use completely custom colors by updating the
--pfe-band--BackgroundColor variable. If you update this value manually, you should also update the
--theme context variable to invoke the right theme on it and it's child elements. Supported themes include:
This is designed for use with the
img-src attribute to allow you to align your background image. Default value is
This allows the customization of a border around the entire container. There is a variable for the entire border shorthand (transparent by default) or you can hook into the individual properties.
You can customize the padding around the outside of the card container by connecting to either the shortcut padding variable or just one or more of the individual padding regions.