Card
<wa-card>
Cards group related content and actions inside a bordered container. Use them to present products, articles, user profiles, or any self-contained unit of information.
This kitten is as cute as he is playful. Bring him home today!
6 weeks old
Examples
Basic Card
Basic cards aren't very exciting, but they can display any content you want them to.
Card with Header
Headers can be used to display titles and more.
If using SSR, you need to also use the with-header attribute to add a header to the card (if not, it is added automatically).
Header Title
This card has a header. You can put all sorts of things in it!Card with Footer
Footers can be used to display actions, summaries, or other relevant content.
If using SSR, you need to also use the with-footer attribute to add a footer to the card (if not, it is added automatically).
Media
Card media is displayed atop the card and will stretch to fit.
If using SSR, you need to also use the with-media attribute to add a media section to the card (if not, it is added automatically).
Appearance
Use the appearance attribute to change the card's visual appearance.
Orientation
Set the orientation attribute to horizontal to create a card with a horizontal, side-by-side layout. Make sure to set a width or maximum width for the media slot. Horizontal cards do not currently contain the header and footer slots.
The actions slot is only available for the horizontal orientation
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.
Import this component directly from the CDN:
import 'https://ka-f.webawesome.com/[email protected]/components/card/card.js';
After installing Web Awesome via npm, import this component:
import '@awesome.me/webawesome/dist/components/card/card.js';
If you're self-hosting Web Awesome, import this component from your server:
import './webawesome/dist/components/card/card.js';
To import this component for React 18 or below, use the following code:
import WaCard from '@awesome.me/webawesome/dist/react/card/index.js';
Slots
Learn more about using slots.
| Name | Description |
|---|---|
| (default) | The card's main content. |
actions
|
An optional actions section to render at the end for the horizontal card. |
footer
|
An optional footer for the card. |
footer-actions
|
An optional actions section to render in the footer of the vertical card. |
header
|
An optional header for the card. |
header-actions
|
An optional actions section to render in the header of the vertical card. |
media
|
An optional media section to render at the start of the card. |
Attributes & Properties
Learn more about attributes and properties.
| Name | Description | Reflects | |
|---|---|---|---|
appearanceappearance |
The card's visual appearance.
Type
'accent' | 'filled' | 'outlined' | 'filled-outlined' | 'plain'Default
'outlined' |
|
|
css |
One or more CSSResultGroup to include in the component's shadow root. Host styles are automatically prepended.
Type
CSSResultGroup | undefinedDefault
[sizeStyles, styles] |
||
orientationorientation |
Renders the card's orientation *
Type
'horizontal' | 'vertical'Default
'vertical' |
|
|
withFooterwith-footer |
Only required for SSR. Set to
true if you're slotting in a footer element so the server-rendered markup
includes the footer before the component hydrates on the client.Type
booleanDefault
false |
|
|
withHeaderwith-header |
Only required for SSR. Set to
true if you're slotting in a header element so the server-rendered markup
includes the header before the component hydrates on the client.Type
booleanDefault
false |
|
|
withMediawith-media |
Only required for SSR. Set to
true if you're slotting in a media element so the server-rendered markup
includes the media before the component hydrates on the client.Type
booleanDefault
false |
|
CSS custom properties
Learn more about CSS custom properties.
| Name | Description |
|---|---|
--spacing |
The amount of space around and between sections of the card. Expects a single value.
Default
var(--wa-space-l)
|
CSS parts
Learn more about CSS parts.
| Name | Description | CSS selector |
|---|---|---|
body |
The container that wraps the card's main content. |
::part(body)
|
footer |
The container that wraps the card's footer. |
::part(footer)
|
header |
The container that wraps the card's header. |
::part(header)
|
media |
The container that wraps the card's media. |
::part(media)
|