Card
A theme-aware, flexible Card component that supports header, body, footer, dividers, and clickable states. Use it to display grouped content or interactive panels consistently across your application.
Usage
Basic usage
import { Card } from '@nofinite/nui';
<Card>
<Card.Header>Profile</Card.Header>
<Card.Body>This is your profile information card.</Card.Body>
</Card>;
With clickable interaction
<Card clickable hover onClick={() => alert('clicked!')}>
<Card.Body>Click me</Card.Body>
</Card>
With footer and divider
<Card>
<Card.Header>Invoice</Card.Header>
<Card.Body>Subtotal: $200</Card.Body>
<Card.Divider />
<Card.Footer>Total: $220</Card.Footer>
</Card>
Variants
Card supports interaction-based variants.
<Card /> // Default card
<Card hover /> // Hoverable card
<Card clickable /> // Clickable card
<Card clickable hover /> // Clickable + hover
Available variants:
default– Standard static cardhover– Card with hover effectclickable– Card that responds to click and keyboard interaction
Guidelines:
- Use
hoverfor subtle visual feedback. - Use
clickablefor cards that trigger actions. - Combine
clickableandhoverfor interactive surfaces.
Sizes
The Card component does not expose predefined size props.
- Control width and spacing using CSS or layout containers.
- Use inline styles only for layout-level overrides when necessary.
<Card style={{ width: '300px' }}>
<Card.Body>Custom width card</Card.Body>
</Card>
States
<Card clickable disabled>
<Card.Body>Disabled clickable card</Card.Body>
</ıll>
Supported interaction states:
clickable– Enables click behavior with keyboard supporthover– Applies hover visual effectdisabled– Visual state only (requires guarding logic inonClick)
Native Props and Composition
Card renders as a semantic <div> and supports standard HTML attributes.
<Card className="my-card" aria-label="User profile card" onClick={handleClick}>
<Card.Header>Profile</Card.Header>
<Card.Body>Content here</Card.Body>
</Card>
Composition is achieved via subcomponents rather than configuration props.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | — | Content rendered inside the Card |
className | string | "" | Custom CSS classes |
clickable | boolean | false | Enables clickable and keyboard behavior |
hover | boolean | false | Enables hover visual effect |
onClick | () => void | — | Click handler (used with clickable) |
Subcomponents
Card.Header– Header sectionCard.Body– Primary content areaCard.Footer– Footer sectionCard.Divider– Visual separator
Behavior Notes
- Clickable cards are keyboard accessible.
EnterandSpacetriggeronClick.- Hover effects are purely visual.
Dividerdoes not introduce additional semantics or interaction.
<Card clickable onClick={() => alert('clicked!')}>
<Card.Body>Click me</Card.Body>
</Card>
Accessibility
- Clickable cards use
role="button"andtabIndex={0}. - Keyboard interaction supports
EnterandSpace. - Use
aria-labelwhen card content alone is insufficient. - Non-interactive cards render as standard
<div>elements.
<Card clickable aria-label="Open profile">
<Card.Body>Profile</Card.Body>
</Card>
Layout
- Cards are block-level elements by default.
- Width is determined by parent container unless constrained.
- Can be expanded to full width using CSS.
<Card style={{ width: '100%' }}>
<Card.Body>Full-width Card</Card.Body>
</Card>
Best Practices
Do
- Use
Card.Header,Card.Body, andCard.Footerfor structured content. - Use
clickableonly when the card represents a clear action. - Use
Dividerto visually separate distinct sections.
Don’t
- Overload a Card with excessive or unrelated functionality.
- Place complex navigation or form logic inside a Card.
- Use
clickablewithout a clear visual or textual affordance.