Card

A container that groups related content and actions, such as a product or a profile.

SC

Saturday Run Club

We meet every Saturday at 8 am for an easy 5 km run. All paces are welcome, and we get coffee afterwards.

Usage

Code
import { Card } from '@leverui/components';
Code
<Card.Root>
  <Card.Header />
  <Card.Body />
  <Card.Footer />
</Card.Root>

Examples

Variants

Use the variant prop to change the visual style of the Card.

SC

Saturday Run Club

An easy 5 km run every Saturday at 8 am. All paces are welcome.

SC

Saturday Run Club

An easy 5 km run every Saturday at 8 am. All paces are welcome.

SC

Saturday Run Club

An easy 5 km run every Saturday at 8 am. All paces are welcome.

Within Form

Use the Card component within a form to group related fields together.

Create your account

Enter your name to get started.

Sizes

Use the size prop to change the size of the Card.

Card size: sm

The padding and the text get bigger as the card size goes up.

Card size: md

The padding and the text get bigger as the card size goes up.

Card size: lg

The padding and the text get bigger as the card size goes up.

With Image

Use the Card component to display an image.

Green two-seat sofa in a living room

Green two-seat sofa

Deep cushions and wooden legs. It fits well in a small living room.

$389

Horizontal

Use the Card component to display content horizontally.

Latte with leaf art in a white cup

House latte

A latte is a shot of espresso topped with steamed milk.

HotCaffeine

With Avatar

Use the Card component to display an avatar.

JR

Jonah Reyes

@jonahreyes

Jonah Reyes wants to join your team. Approve or decline the request.

Customization

Adding new variants

Give the card a class and style it. Load your CSS after the Lever UI stylesheet.

Code
<Card.Root class="card-gradient">
  <Card.Body>Content</Card.Body>
</Card.Root>
Code
.card-gradient {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

Adding new sizes

Set --leverui-card-padding in your own class.

Code
.card-xl {
  --leverui-card-padding: var(--leverui-spacing-10);
}

.card-xl .leverui-card__title {
  font-size: var(--leverui-font-sizes-2xl);
}

Changing defaults

Card.PropsProvider sets default props for the cards inside it. A prop on a card wins.

Code
<Card.PropsProvider value={{ variant: 'elevated', size: 'lg' }}>
  <Card.Root>
    <Card.Body>Content</Card.Body>
  </Card.Root>
</Card.PropsProvider>

Updating the theme

Set --leverui-* variables on :root for every card, or on a class for some. See the theme guide.

Props

Root

PropDefaultTypeDescription
sizemd'sm' | 'md' | 'lg'Card size. Responsive.
variantoutline'elevated' | 'outline' | 'subtle'Card style. Responsive.
asdivNative HTML tagHTML tag to render.
asChild—Solid render functionRender your own element with the card's props.
unstyledfalsebooleanTurn off the Lever UI styles.

Card.Title renders an h3 and Card.Description a p. Pass as to change the tag.

Classes: .leverui-card__root, __header, __body, __footer, __title, __description.

Explorer

Click a part name to highlight it in the preview.

Component Anatomy

Hover to highlight, click to select parts