Cards â Svelte
Cards component â Svelte.
Card component
The Card component provides a flexible container for organizing content with variants, sections, and image support.
Basic usage
The simplest card usage:
Card Title
This is a basic card with default styling. It uses semantic theme variables and adapts to all themes.
Card variants
Cards support four variants for different visual styles:
Default
Default Card
Standard card with border and background.
Elevated
Elevated Card
Card with shadow effect. Hover to see it lift up.
Outlined
Outlined Card
Transparent background with border. Hover to see accent border.
Filled
Filled Card
Uses main background color instead of alt background.
Card sections
Use card sections for structured layouts with header, body, and footer:
Card Title
Card subtitle or description
This is the main content area of the card. It can contain any content you need.
Multiple paragraphs, lists, or other elements work great here.
Section classes
card__headerâ Header section with bottom bordercard__bodyâ Main content area (flexible, takes remaining space)card__footerâ Footer section with top bordercard__titleâ Title styling for headercard__subtitleâ Subtitle styling for header
Card with image
Add an image to your card using the card__image class:
Card with Image
This card includes an image at the top. The image automatically adjusts to the card's border radius.
Complete example
Complete Card Example
With image, header, body, and footer
This is a complete card example showcasing all features:
- Image at the top
- Structured header with title and subtitle
- Flexible body content
- Footer with actions
Props
variant('default' | 'elevated' | 'outlined' | 'filled', optional) â Card variant style (default: 'default')class(string, optional) â Additional CSS classes
Usage
<script>
import Card from './components/svelte/Card.svelte';
</script>
<Card variant="elevated">
<div class="card__header">
<h3 class="card__title">Card Title</h3>
<p class="card__subtitle">Subtitle text</p>
</div>
<div class="card__body">
<p>Main content area</p>
</div>
<div class="card__footer">
<button class="btn btn-primary">Action</button>
</div>
</Card>