Card
A versatile and accessible container that groups related content with support for multiple visual variants.
Installation
Install the component directly into your project using the Pittaya CLI.
npx pittaya@latest add card
When to use
Use the Card to group related information in a visual and hierarchical way, such as user profiles, blog articles, products in an online store, or any content that benefits from a container with defined borders and spacing.
The component is ideal for creating grid layouts or item lists that need to stand out from the page background, maintaining visual consistency through the available variants.
Best practices
- Use
CardHeaderfor titles and descriptions, keeping the visual hierarchy clear and predictable. - Prefer
CardContentfor the main content andCardFooterfor actions or secondary metadata. - Choose variants that convey the card's function: use
gradientto highlight premium items orliftedfor interactive elements. - Avoid overloading a single card with too much information; prefer splitting content into multiple cards when necessary.
- Combine with components like
ButtonandBadgeto create complete and functional interfaces.
Accessibility
The Card is rendered as a semantic div, but you can add ARIA attributes when it contains interactive content or is part of a navigation pattern.
When using clickable cards, wrap all content in a button or a element to ensure that keyboard users can access the main action without difficulty.
Make sure variant colors maintain adequate contrast in both light and dark mode, especially in decorative variants like crosshair and corners.
Examples
Combine variants and sizes to meet your needs.
Product card
A typical card for displaying products in e-commerce, combining image, title, description, price, and purchase action.
User profile
Card with lifted variant to highlight profile information on dashboards or team pages.
Premium pricing card
Gradient variant to highlight premium plans or special offers on pricing pages.
Statistics card
ShadowRight variant for dashboards with metrics and performance indicators.
Custom shadow colors
Demonstration of shadowRight variant with different custom shadow colors to match your brand or design system.
Blog post card
Default card for article listings with featured image, title, description, and metadata.
Notification card
Corners variant to highlight notifications, alerts, or important messages.
Gradient feature card
Gradient variant with custom colors to highlight premium features or special offers.
Technical specification
Crosshair variant for technical documentation, API specs, or development-related content.
All variants
Visual demonstration of all available variants.
Properties
TSX interface that combines variants and default attributes.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'default' | 'crosshair' | 'lifted' | 'shadowRight' | 'gradient' | 'corners' | 'default' | Defines the visual style of the card. Each variant offers a unique appearance suitable for different contexts. |
shadowColor | string | — | Custom color for the shadow when variant='shadowRight'. Accepts any valid CSS color (hex, rgb, color name). Defaults to black. |
gradientClassName | string | — | Custom Tailwind classes for the border gradient when variant='gradient'. Overrides the default gradient. |
className | string | — | Additional Tailwind classes to customize the card style. |