Card

Card

A versatile container component for displaying content with support for images, headers, footers, and interactive states.


Import

tsx
import { Card } from "asheeui";

Usage

tsx
import { Card } from "asheeui";
export default function Basic() {
return (
<Card
title="Card Title"
description="This is a description that provides additional context about the card content."
body="Main card content goes here. This can be any React node."
className="max-w-sm"
/>
);
}

Examples

Variant

Bordered

The bordered card style.

Use the variant prop to change how a card separates itself from the page background.

Elevated

The elevated card style.

Use the variant prop to change how a card separates itself from the page background.

Flat

The flat card style.

Use the variant prop to change how a card separates itself from the page background.

Ghost

The ghost card style.

Use the variant prop to change how a card separates itself from the page background.

Size

Small card

Adjust padding and internal spacing with the size prop.

This card demonstrates how the content area scales across supported sizes.

Medium card

Adjust padding and internal spacing with the size prop.

This card demonstrates how the content area scales across supported sizes.

Large card

Adjust padding and internal spacing with the size prop.

This card demonstrates how the content area scales across supported sizes.

Radius

None

Corner rounding applied via the radius prop.

Extra Small

Corner rounding applied via the radius prop.

Small

Corner rounding applied via the radius prop.

Medium

Corner rounding applied via the radius prop.

Large

Corner rounding applied via the radius prop.

Extra Large

Corner rounding applied via the radius prop.

Full

Corner rounding applied via the radius prop.

With image (top)

Abstract artwork

Image on top

A video-ratio image sits above the card content.

Give the image prop a position of top to place an image above the content.

With image (background)

Colorful abstract 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.

Give the image prop a position of bottom to place an image below the content.
Abstract artwork
Account

Update your profile

Keep your account details up to date.

Your name and avatar are shown to other members when you collaborate.

Clickable card

Free

per month

$0

Pro

per month

$9

Team

per month

$29

Disabled state

Disabled card

Cards can be locked while content is still displayed.

A disabled card prevents interaction and reduces its visual emphasis.

Locked card

This card cannot be clicked.

Disabled cards use reduced opacity and ignore pointer events.

With animation

Animated

Press to feel the scale effect.

animate adds a subtle press-down scale on click.

Static

No motion feedback.

animate={false} disables the press scale entirely.

Custom styling

Custom styled card

Tailwind utilities merge with the built-in card styles.

Pass any extra classes through the className prop to fully control the look.

With custom image component

Mountain landscape

Next.js Image

Using Next.js Image component for automatic optimization


Props

PropTypeDefaultDescription
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
titleReactNodeNoneCard title
descriptionReactNodeNoneCard description text
headerReactNodeNoneCustom header content
bodyReactNodeNoneMain card content
footerReactNodeNoneFooter content
childrenReactNodeNoneAlternative to body prop
imageSrcstringNoneImage source URL
imageAltstring""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
imageComponentReact.ElementTypeNoneCustom image component (e.g., Next.js Image). Replaces the native <img> tag for card images.
imagePropsRecord<string, unknown>NoneAdditional props for custom image component (e.g., { priority: true, sizes: "..." }).
isClickablebooleanfalse*Enables card as interactive element
isDisabledbooleanfalseDisables interaction
animatebooleantrue*Enables hover/tap motion
hrefstringNoneURL for navigation (clickable card)
onClick(e: MouseEvent) => voidNoneClick handler
classNamestringNoneExtra 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:

  1. Instance prop: set directly on <Card />
  2. Component config: components.card in your ashee.config
  3. Theme default: defaultVariant / defaultRadius in your ashee.config
  4. Built-in fallback: component's internal default values

Component config

ts
// ashee.config.ts
import type { ExternalConfig } from "asheeui";
export const config: ExternalConfig = {
components: {
card: {
variant: "elevated",
size: "md",
radius: "md",
imagePosition: "top",
imageRatio: "video",
imageFit: "cover",
isClickable: false,
animate: true,
},
},
};

Built-in fallbacks

ts
{
size: "md",
variant: "bordered",
radius: "md",
imagePosition: "top",
imageRatio: "video",
imageFit: "cover",
isClickable: false,
animate: true,
}

Accessibility

  • Renders as a <div> element when clickable for proper semantics
  • Uses role="link" when href is provided
  • Uses aria-disabled for disabled state
  • Implements focus-visible rings for keyboard navigation
  • Supports keyboard interaction with Enter and Space keys
  • Image alt text is required for accessibility

Notes

  • Clickable Cards: When isClickable is true or href/onClick is provided, the card becomes interactive with hover effects and keyboard support.
  • Animation: The animate prop adds a subtle scale effect on click. It's enabled by default for clickable cards.
  • Children vs Body: Use children for simple content or body for explicit body content. If both are provided, body takes precedence.
  • Image Fit: The imageFit prop controls how the image fills its container using CSS object-fit values.
  • Variant Styles: elevated includes a shadow, bordered has a border, flat has a subtle background, and ghost has no background or border.
  • Custom Image Component: You can replace the native <img> with any custom image component (e.g., Next.js Image) using the imageComponent prop. The component works with all image positions (top, bottom, background) and preserves all styling, ratios, and fit behaviors.
Previous

← Button

Next

Carousel →