Sina UI

Display

Card

Groups related content on a raised surface.

Installation

npx sinaui add card

Examples

With actions

The Canon of Medicine

Ibn Sina, completed 1025. Five books.

The standard medical text in the Islamic world and in Europe for centuries.
<script lang="ts">
	import Button from '#lib/ui/Button.svelte';
	import Card from '#lib/ui/Card.svelte';
</script>

<Card title="The Canon of Medicine" description="Ibn Sina, completed 1025. Five books.">
	The standard medical text in the Islamic world and in Europe for centuries.
	{#snippet footer()}
		<Button size="sm" variant="ghost">Preview</Button>
		<Button size="sm">Borrow</Button>
	{/snippet}
</Card>

With an icon

A small icon beside the title tells sections apart at a glance, as on a settings page. It's decoration: the title still names the card.

Readers

Who can borrow from the House of Wisdom.

Scholars, translators and copyists, by invitation.

Reminders

When a book is due back.

A note three days before, and again on the day.
<script lang="ts">
	import { Notification01Icon, UserGroupIcon } from '@hugeicons/core-free-icons';
	import Card from '#lib/ui/Card.svelte';
</script>

<div class="stack">
	<Card title="Readers" description="Who can borrow from the House of Wisdom." icon={UserGroupIcon}>
		Scholars, translators and copyists, by invitation.
	</Card>
	<Card title="Reminders" description="When a book is due back." icon={Notification01Icon}>
		A note three days before, and again on the day.
	</Card>
</div>

<style>
	.stack {
		display: grid;
		gap: 1rem;
	}
</style>

As a link

The title’s link stretches over the whole card, so it is one link with one name, and buttons inside still work.

<script lang="ts">
	import Card from '#lib/ui/Card.svelte';

	const scholars = [
		{ name: 'Al-Khwarizmi', work: 'Algebra and algorithms, Baghdad', href: '#linked' },
		{
			name: 'Ibn al-Haytham',
			work: 'Optics and the scientific method, Cairo',
			href: '#linked'
		},
		{ name: 'Fatima al-Fihri', work: 'Founded al-Qarawiyyin, Fez', href: '#linked' }
	];
</script>

<!-- The whole card is one link, named by its title. -->
<div class="cards">
	{#each scholars as s (s.name)}
		<Card title={s.name} description={s.work} href={s.href} />
	{/each}
</div>

<style>
	.cards {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
		gap: 1rem;
		inline-size: 100%;
	}
</style>

Danger zone

tone="danger" gives a red edge and title. Each action is a row: what it does on the left, a normal-sized button on the right.

Danger zone

Close the reading room

Its loans end today and its catalog is archived. You can reopen it within 30 days.

Delete the library

Every room, member and loan record, for good. This can’t be undone.

<script lang="ts">
	import Card from '#lib/ui/Card.svelte';
	import ConfirmButton from '#lib/ui/ConfirmButton.svelte';
	import { toast } from '#lib/ui/toast/index.js';
</script>

<Card title="Danger zone" tone="danger">
	<div class="row">
		<div>
			<strong>Close the reading room</strong>
			<p>Its loans end today and its catalog is archived. You can reopen it within 30 days.</p>
		</div>
		<ConfirmButton size="sm" onconfirm={() => toast('Reading room closed.')} confirm="Close it?">
			Close room
		</ConfirmButton>
	</div>
	<div class="row">
		<div>
			<strong>Delete the library</strong>
			<p>Every room, member and loan record, for good. This can’t be undone.</p>
		</div>
		<ConfirmButton
			size="sm"
			onconfirm={() => toast('Library deleted.')}
			confirm="Delete everything?"
		>
			Delete library
		</ConfirmButton>
	</div>
</Card>

<style>
	.row {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		gap: 0.75rem 1.5rem;
	}
	.row + .row {
		padding-block-start: 0.75rem;
		border-block-start: 1px solid var(--ui-line);
	}
	p {
		margin: 0.125rem 0 0;
		color: var(--ui-muted);
	}
</style>

Props

PropTypeDefault
titlestring
descriptionstring
iconHugeicons icon: beside the title, decorative
level2 | 3 | 4: heading level3
hrefstring: whole card links
footerSnippet
asideSnippet: beside the title (a switch, a count, a link)
flushboolean: the panel's content runs edge to edgefalse
tone'danger': a red edge and title, for actions that can't be undone
selectedboolean: chosen from a set of cardsfalse

Accessibility

  • An <article> headed by its title at the level you choose, so it fits the page outline.
  • Linked cards use a stretched link, not a link around the card: one short, clear name instead of the whole card read aloud.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Theme toggle
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Account menu
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Sparkline
World map
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Docs navigation
Menubar
Navigation menu
Pagination
Sidebar layout
Stat tabs
Stepper
Tabs
Table of contents
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
Docs
File explorer
Messaging
Notifications
Settings
Studio
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme