Skip to content
Sveltier
Mode
Components

Card

A surface that groups content about one thing: a header with a title, the content, and actions.

Usage

A Card is a raised surface in the theme's colours. Its header holds a title, a subtitle and what you put in prepend and append; the content follows, and actions close it. Every variant works; a neutral outline uses the theme's border colour.

Savings

Instant access · 4.1% AER

$12,480.00

+ $120.00 this month
Outlined
Pending · $310.25
Tonal
Pending · $310.25
Flat
Pending · $310.25
SavingsCard.svelte
<script>
  import { Avatar, Button, Card } from 'sveltier';
</script>

<Card title="Savings" subtitle="Instant access" level={3}>
  {#snippet prepend()}<Avatar color="success">SV</Avatar>{/snippet}
  <p>$12,480.00</p>
  {#snippet actions()}
    <Button variant="tonal">Add money</Button>
    <Button variant="text">Statement</Button>
  {/snippet}
</Card>

Accessibility

  • Set level to make the title a heading of that level, so the card is in the page's outline. Pick the level that follows the heading above it.
  • A card is not a control. Make what it leads to a link or a button inside it, so each action has its own name and the card's text stays readable.

API

NameTypeDefaultDescription
variant'elevated' | 'flat' | 'tonal' | 'outlined' | 'text' | 'plain''elevated'Visual weight: a raised surface by default.
colorColor'neutral'The colour the variant is painted with. Neutral cards use the theme's surface, text and border colours.
density'compact' | 'default' | 'comfortable''default'Multiplies the padding and the space between sections.
roundedboolean | 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'trueCorner rounding. true keeps the theme's radius.
titlestring–The title, in the header.
subtitlestring–A line under the title.
level1 | 2 | 3 | 4 | 5 | 6–Makes the title a heading of this level (<h2>, <h3>…), so it is in the page's outline. Without it the title is styled text.
prependSnippet–Content before the title, such as an avatar or an icon.
appendSnippet–Content after the title, such as a menu button.
actionsSnippet–Buttons or links at the bottom.
childrenSnippet–The content.
classClassValue | null–Classes added after the component's own: a string, an array or an object.
refHTMLDivElement | null–The root element, bindable with bind:ref.