Card
A versatile container component for displaying content with support for images, headers, footers, and interactive states.
Import
Usage
Examples
Variant
Bordered
The bordered card style.
Elevated
The elevated card style.
Flat
The flat card style.
Ghost
The ghost card style.
Size
Small card
Adjust padding and internal spacing with the size prop.
Medium card
Adjust padding and internal spacing with the size prop.
Large card
Adjust padding and internal spacing with the size prop.
Radius
None
Extra Small
Small
Medium
Large
Extra Large
Full
With image (top)
Image on top
A video-ratio image sits above the card content.
With image (background)
Background image
The image fills the entire card behind the content.
Content sits on top of the image. Use a scrim or semi-transparent panel to keep text readable.
With image (bottom)
Image on bottom
A video-ratio image sits below the card content.
With header and footer
Update your profile
Keep your account details up to date.
Clickable card
Free
per month
Pro
per month
Team
per month
Disabled state
Disabled card
Cards can be locked while content is still displayed.
Locked card
This card cannot be clicked.
With animation
Animated
Press to feel the scale effect.
Static
No motion feedback.
Custom styling
Custom styled card
Tailwind utilities merge with the built-in card styles.
With custom image component
Next.js Image
Using Next.js Image component for automatic optimization
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "elevated" | "bordered" | "flat" | "ghost" | "bordered"* | Visual style of the card |
size | "sm" | "md" | "lg" | "md"* | Size scale for padding and gaps |
radius | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "full" | "md"* | Corner rounding |
title | ReactNode | None | Card title |
description | ReactNode | None | Card description text |
header | ReactNode | None | Custom header content |
body | ReactNode | None | Main card content |
footer | ReactNode | None | Footer content |
children | ReactNode | None | Alternative to body prop |
imageSrc | string | None | Image source URL |
imageAlt | string | "" | Image alt text |
imagePosition | "top" | "bottom" | "background" | "top"* | Image placement |
imageRatio | "auto" | "square" | "video" | "portrait" | "video"* | Aspect ratio of image |
imageFit | "cover" | "contain" | "fill" | "none" | "scale-down" | "cover"* | How image fits its container |
imageComponent | React.ElementType | None | Custom image component (e.g., Next.js Image). Replaces the native <img> tag for card images. |
imageProps | Record<string, unknown> | None | Additional props for custom image component (e.g., { priority: true, sizes: "..." }). |
isClickable | boolean | false* | Enables card as interactive element |
isDisabled | boolean | false | Disables interaction |
animate | boolean | true* | Enables hover/tap motion |
href | string | None | URL for navigation (clickable card) |
onClick | (e: MouseEvent) => void | None | Click handler |
className | string | None | Extra classes, merged with internal styles |
* Falls back through Global Configuration if not set. See below.
Global Configuration
Card reads defaults from four places, in this order of precedence:
- Instance prop: set directly on
<Card /> - Component config:
components.cardin yourashee.config - Theme default:
defaultVariant/defaultRadiusin yourashee.config - Built-in fallback: component's internal default values
Component config
Built-in fallbacks
Accessibility
- Renders as a
<div>element when clickable for proper semantics - Uses
role="link"whenhrefis provided - Uses
aria-disabledfor disabled state - Implements
focus-visiblerings for keyboard navigation - Supports keyboard interaction with Enter and Space keys
- Image alt text is required for accessibility
Notes
- Clickable Cards: When
isClickableistrueorhref/onClickis provided, the card becomes interactive with hover effects and keyboard support. - Animation: The
animateprop adds a subtle scale effect on click. It's enabled by default for clickable cards. - Children vs Body: Use
childrenfor simple content orbodyfor explicit body content. If both are provided,bodytakes precedence. - Image Fit: The
imageFitprop controls how the image fills its container using CSSobject-fitvalues. - Variant Styles:
elevatedincludes a shadow,borderedhas a border,flathas a subtle background, andghosthas no background or border. - Custom Image Component: You can replace the native
<img>with any custom image component (e.g., Next.jsImage) using theimageComponentprop. The component works with all image positions (top,bottom,background) and preserves all styling, ratios, and fit behaviors.