Card

A container component for grouping related content and actions, providing visual separation and hierarchy.

Anatomy

<script>
  import {
    Card,
    CardHeader,
    CardBody,
    CardFooter,
    CardTitle,
    CardDescription,
  } from "@saas-ui/svelte/components/card";
</script>

<Card.Root>
  <CardHeader>
    <CardTitle>Card Title</CardTitle>
    <CardDescription>Card description goes here</CardDescription>
  </CardHeader>
  <CardBody>
    <p>Main content of the card goes here.</p>
  </CardBody>
  <CardFooter>
    <Button>Action</Button>
  </CardFooter>
</Card.Root>

Examples

Basic Accessibility

Basic card with header, body, and footer sections.

Horizontal Accessibility

Horizontal card layout with side-by-side content arrangement.

Sizes Accessibility

Use the size prop to change the size of the card. Available sizes: sm, md, lg.

Variants Accessibility

Use the variant prop to change the visual style. Available variants: subtle, outline, elevated.

With Avatar Accessibility

Card displaying user profile information with avatar.

With Form Accessibility

Card containing a form with input fields and submit button.

With Image Accessibility

Card with an image element for visual content display.

Props

Card.Root

The main card container.

Prop Type Default Description
children Snippet - The card content.
variant "subtle" | "outline" | "elevated" "outline" The visual style of the card.
size "sm" | "md" | "lg" "md" The size of the card.
class string - Additional CSS classes to apply.
style string - Inline styles to apply to the card.

Card.Header

The header section of the card.

Prop Type Default Description
children Snippet - The header content.
class string - Additional CSS classes to apply.

Card.Body

The body section of the card.

Prop Type Default Description
children Snippet - The body content.
class string - Additional CSS classes to apply.

The footer section of the card.

Prop Type Default Description
children Snippet - The footer content.
class string - Additional CSS classes to apply.

Card.Title

The title element within the card header.

Prop Type Default Description
children Snippet - The title content.
class string - Additional CSS classes to apply.

Card.Description

The description element within the card header.

Prop Type Default Description
children Snippet - The description content.
class string - Additional CSS classes to apply.