A Card summarizes an object that a user can select or navigate to.
Card titleCard description. Give a concise overview of the context or functionality that's mentioned in the card title.
variant
The visual style of the Card.
variant
size
density
The amount of internal padding within the Card.
density
import {Card, CardPreview, Image, Content, Text, ActionMenu, MenuItem, Footer, StatusLight} from'@react-spectrum/s2';
importpreviewfrom'url:./assets/preview.png';
<Card>
<CardPreview>
<Imagesrc={preview} />
</CardPreview>
<Content>
<Textslot="title">Card title</Text>
<ActionMenu>
<MenuItem>Edit</MenuItem>
<MenuItem>Share</MenuItem>
<MenuItem>Delete</MenuItem>
</ActionMenu>
<Textslot="description">Card description. Give a concise overview of the context or functionality that's mentioned in the card title.</Text>
</Content>
<Footer>
<StatusLightsize="S"variant="positive">Published</StatusLight>
</Footer>
</Card>
Content
Cards are flexible containers that represent objects a user can select or navigate to. Most cards include a preview, metadata, and an optional footer. Spectrum includes several pre-defined card components with layouts for specific use cases, or you can combine these sections to create custom cards.
Asset
A AssetCard represents an asset such as an image, video, document, or folder. The CardPreview can contain either an Image or illustration. By default, images are displayed in a square preview without cropping. Add metadata in the Content section using the title and description slots.
A UserCard represents a user profile. It includes an Avatar and a Content section with title and description slots, along with an optional header image and Footer.
Simone CarterArt Director at Luma Creative Studios. Visual storyteller and coffee enthusiast.
A ProductCard represents a product a user can take action on. It has a a thumbnail image and a Content section with title and description slots, a Footer containing a call to action, and an optional header image.
Command + RYour all-in-one shortcut for apps, automations, and devices.
A CollectionCardPreview displays up to 4 images in a collection of assets. When 4 images are provided, the first one is displayed as a larger hero image.
A card can omit its Content section and display only a preview to create a gallery card typically seen in a waterfall layout. Ensure that the preview image has alt text, and any content placed above the preview has enough contrast against the background.
Free
size
import {Card, CardPreview, Image, Badge, Avatar} from'@react-spectrum/s2';
import {style} from'@react-spectrum/s2/style'with {type: 'macro'};
<Card>
<CardPreview>
<Imagealt="Narrow mountain trail with green grass and sharp peaks in the background"src="https://images.unsplash.com/photo-1722233987129-61dc344db8b6?q=80&w=600&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"styles={style({width: 'full', aspectRatio: 'square', objectFit: 'cover', pointerEvents: 'none'})} />
<Badgevariant="yellow"styles={style({
position: 'absolute',
top: 16,
insetEnd: 16
})}>
Free
</Badge>
<Avatarsrc="https://i.imgur.com/xIe7Wlb.png"size={24}
isOverBackgroundstyles={style({
position: 'absolute',
bottom: 16,
insetStart: 16
})} />
</CardPreview>
</Card>
Custom
Combine the CardPreview, Content, and Footer components to create custom cards. Add additional elements and styles within these sections to create custom layouts as needed.
Wrap a card in a Skeleton to display a loading state. Placeholder text content and images are displayed in a skeleton style.
Placeholder titleThis is placeholder content approximating the length of the real content to avoid layout shifting when the real content appears.
isLoading
import {Skeleton, Card, CardPreview, Image, Content, Text} from'@react-spectrum/s2';
<SkeletonisLoading>
<Card>
<CardPreview>
<Imagesrc="https://images.unsplash.com/photo-1705034598432-1694e203cdf3?q=80&w=600&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" />
</CardPreview>
<Content>
<Textslot="title">Placeholder title</Text>
<Textslot="description">This is placeholder content approximating the length of the real content to avoid layout shifting when the real content appears.</Text>
</Content>
</Card>
</Skeleton>