PeakUI

Card

A content container with header, body and footer

Usage

import {Card} from "@peakui/react";

Anatomy

import {Card} from "@peakui/react";

export default () => (
  <Card>
    <Card.Header>
      <Card.Title>Title</Card.Title>
      <Card.Description>Description</Card.Description>
    </Card.Header>
    <Card.Content>Content</Card.Content>
    <Card.Footer>Footer</Card.Footer>
  </Card>
);

Examples

Variants

Horizontal Layout

Width and direction come from the consumer.

Compact Cards

With Form

Card.Content is the body region; the form wraps it without breaking the card's padding.

Customization

Tailwind CSS

<Card className="w-[400px] gap-4 md:flex-row">Content</Card>

Global CSS

@layer components {
  .card {
    border-radius: min(16px, var(--radius-2xl));
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The Card component uses these CSS classes (view source styles):

Base Class

  • .card - Base card styles: flex column, gap, padding, surface shadow and radius

Variant Classes

  • .card--default - bg-surface
  • .card--secondary - bg-surface-secondary
  • .card--tertiary - bg-surface-tertiary
  • .card--transparent - No background, border or shadow

Element Classes

  • .card__header - Header region: flex column
  • .card__title - Title: h3 text styles
  • .card__description - Description: p text styles
  • .card__content - Body region: flex column, takes the remaining space
  • .card__footer - Footer region: flex row, centered

Slots

  • [data-slot="card"] - The root element
  • [data-slot="card-header"] - The header region
  • [data-slot="card-title"] - The title
  • [data-slot="card-description"] - The description
  • [data-slot="card-content"] - The body region
  • [data-slot="card-footer"] - The footer region

API Reference

Card

PropTypeDefaultDescription
childrenReactNode-The card content (required)
variant'default' | 'secondary' | 'tertiary' | 'transparent''default'Surface level the card paints
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element

Every other attribute of a <div> is accepted.

Every variant except transparent provides SurfaceContext, so nested controls re-base their fills on the card's level.

Card.Header

PropTypeDefaultDescription
childrenReactNode-The header content
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element

Every other attribute of a <div> is accepted.

Card.Title

PropTypeDefaultDescription
childrenReactNode-The title text
classNamestring-Additional classes
renderDOMRenderFunction<'h3', undefined>-Replaces the rendered <h3> with your own element

Every other attribute of an <h3> is accepted.

Card.Description

PropTypeDefaultDescription
childrenReactNode-The description text
classNamestring-Additional classes
renderDOMRenderFunction<'p', undefined>-Replaces the rendered <p> with your own element

Every other attribute of a <p> is accepted.

Card.Content

PropTypeDefaultDescription
childrenReactNode-The body content
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element

Every other attribute of a <div> is accepted.

Card.Footer

PropTypeDefaultDescription
childrenReactNode-The footer content
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element

Every other attribute of a <div> is accepted.

On this page