Overview
Card is a production-ready card component included in the sunpeak Starter Kit. It provides a flexible interface for displaying rich content with optional images, headers, metadata, and up to two action buttons.
Import
Basic Usage
Props
children
- Type:
React.ReactNode - Optional: Yes
- Description: The main content/description displayed in the card body. Limited to 2 lines with ellipsis overflow.
image
- Type:
string - Optional: Yes
- Description: URL or path to the image displayed at the top of the card.
imageAlt
- Type:
string - Optional: Yes
- Description: Alt text for the image for accessibility.
imageMaxWidth
- Type:
number - Optional: Yes
- Default:
400 - Description: Maximum width of the image in pixels.
imageMaxHeight
- Type:
number - Optional: Yes
- Default:
400 - Description: Maximum height of the image in pixels.
header
- Type:
React.ReactNode - Optional: Yes
- Description: The card header/title. Displays with medium font weight and truncates with ellipsis if too long.
metadata
- Type:
React.ReactNode - Optional: Yes
- Description: Secondary metadata displayed below the header (e.g., ratings, location, price).
button1
- Type:
OpenAIButtonProps - Optional: Yes
- Description: Configuration for the first action button.
button2
- Type:
OpenAIButtonProps - Optional: Yes
- Description: Configuration for the second action button.
variant
- Type:
"default" | "bordered" | "elevated" - Optional: Yes
- Default:
"default" - Description: Visual style variant of the card.
default: Subtle border with surface backgroundbordered: Thicker border with surface backgroundelevated: Subtle border with surface background and shadow
className
- Type:
string - Optional: Yes
- Description: Additional CSS classes to apply to the card container.
onClick
- Type:
(e: React.MouseEvent<HTMLDivElement>) => void - Optional: Yes
- Description: Click handler for the entire card. Button clicks are prevented from bubbling to this handler.