NUIv3.0.7

Card

A composable, accessible Card component for modern React applications.

tsx
import { Card } from '@nofinite/nui';

Interactive Preview

Loading preview...

A flexible container component used to group related content and actions. Supports structured sections (Header, Body, Footer, Divider), hover elevation, and clickable behavior with built-in accessibility.


Usage

Basic Card

tsx
import { Card } from '@nofinite/nui';

<Card>
  <Card.Header>Card Title</Card.Header>
  <Card.Body>
    This is the card content area where you can place text or elements.
  </Card.Body>
</Card>;
tsx
<Card>
  <Card.Header>Project</Card.Header>

  <Card.Body>Manage project details and tasks.</Card.Body>

  <Card.Footer>
    <Button size="sm">Edit</Button>
    <Button size="sm" variant="outline">
      View
    </Button>
  </Card.Footer>
</Card>

Clickable Card

tsx
<Card clickable onClick={() => console.log('Clicked')}>
  <Card.Header>Interactive Card</Card.Header>
  <Card.Body>Entire card behaves like a button.</Card.Body>
</Card>

Hover Elevation Card

tsx
<Card hover>
  <Card.Header>Hover Card</Card.Header>
  <Card.Body>Card elevates visually on hover.</Card.Body>
</Card>

Card with Divider

tsx
<Card>
  <Card.Header>Pricing</Card.Header>

  <Card.Body>Basic plan features</Card.Body>

  <Card.Divider />

  <Card.Footer>
    <Button variant="primary">Upgrade</Button>
  </Card.Footer>
</Card>


Subcomponents

Card.Header

Container for card titles or heading content.

PropTypeDescription
childrenReact.ReactNodeHeader content
classNamestringAdditional styles

Card.Body

Primary content area of the card.

PropTypeDescription
childrenReact.ReactNodeMain content
classNamestringAdditional styles

Action or metadata area typically placed at the bottom.

PropTypeDescription
childrenReact.ReactNodeFooter content
classNamestringAdditional styles

Card.Divider

Full-width separator for visual grouping.

PropTypeDescription
classNamestringAdditional styles
...restReact.HTMLAttributes<HTMLHRElement>Native hr props

States / Behavior

StateDescription
DefaultSubtle border and shadow container
HoverElevates card with stronger shadow
ClickableAdds pointer cursor, hover border, and press scale
Focus-visibleAccessible focus ring for keyboard navigation

Layout & Structure

SectionPurpose
HeaderTitle or summary information
BodyMain content region
DividerVisual separation between sections
FooterActions or metadata


Accessibility

  • Clickable cards expose button semantics using role="button" and tabIndex=0
  • Keyboard interaction supported via Enter and Space triggers
  • Focus-visible ring ensures keyboard discoverability
  • Divider uses semantic <hr>
  • Header, Body, and Footer preserve structural grouping

Best Practices

Do

  • Use cards to group related content and actions
  • Use clickable cards for dashboards, lists, or navigation surfaces
  • Keep header concise and descriptive
  • Use divider to separate logical sections

Don’t

  • Place critical interactive controls inside a clickable card without clear affordance
  • Overload cards with excessive content
  • Use clickable cards for destructive actions
  • Nest too many cards creating visual clutter

API Reference

PropTypeDefaultDescription
clickablebooleanfalseIf true, makes the card interactive via mouse and keyboard (Enter/Space)
hoverbooleanfalseIf true, adds a shadow elevation effect on hover