The Canon of Medicine
Ibn Sina, completed 1025. Five books.
Display
Groups related content on a raised surface.
npx sinaui add cardCopy src/lib/ui/Card.svelte and tokens.css. No dependencies.
Ibn Sina, completed 1025. Five books.
<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>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.
<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>The title’s link stretches over the whole card, so it is one link with one name, and buttons inside still work.
Algebra and algorithms, Baghdad
Optics and the scientific method, Cairo
Founded al-Qarawiyyin, Fez
<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>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.
Its loans end today and its catalog is archived. You can reopen it within 30 days.
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>| Prop | Type | Default |
|---|---|---|
title | string | |
description | string | |
icon | Hugeicons icon: beside the title, decorative | |
level | 2 | 3 | 4: heading level | 3 |
href | string: whole card links | |
footer | Snippet | |
aside | Snippet: beside the title (a switch, a count, a link) | |
flush | boolean: the panel's content runs edge to edge | false |
tone | 'danger': a red edge and title, for actions that can't be undone | |
selected | boolean: chosen from a set of cards | false |
<article> headed by its title at the level you choose, so it fits the page outline.