Layout & Containers
Card
A surface container that groups related content. Compose it with nana-card-header, nana-card-title, nana-card-description, nana-card-content and nana-card-footer.
Preview
Section titled “Preview”<nana-card style="max-width: 22rem">
<nana-card-header>
<nana-card-title>Card title</nana-card-title>
<nana-card-description>
A short supporting description.
</nana-card-description>
</nana-card-header>
<nana-card-content>
A card groups related content into a single surface.
</nana-card-content>
<nana-card-footer>
<nana-button size="sm">Action</nana-button>
</nana-card-footer>
</nana-card> Installation
Section titled “Installation”The card ships for all three targets. Pick the tab for your project — the CLI detects which you are on and serves the matching implementation.
npx @nana-tec/ui add cardLands as src/components/ui/card/card.tsx, styled with Tailwind classes that
resolve to the design tokens. Requires Tailwind v4.
npx @nana-tec/ui add cardLands in src/lib/components/ui/card/ as Card.svelte, CardHeader.svelte, CardTitle.svelte, CardDescription.svelte, CardContent.svelte and CardFooter.svelte, styled with Tailwind
classes that resolve to the design tokens. Requires Tailwind v4.
Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add cardimport { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter,} from "@/components/ui/card";import { Button } from "@/components/ui/button";
export function Example() { return ( <Card variant="elevated"> <CardHeader> <CardTitle>Card title</CardTitle> <CardDescription>A short supporting description.</CardDescription> </CardHeader> <CardContent>A card groups related content into a single surface.</CardContent> <CardFooter> <Button size="sm">Action</Button> </CardFooter> </Card> );}Every part is optional and each is a plain div (or h3 / p for the title
and description), so you can compose or skip them freely.
<script lang="ts"> import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, } from '$lib/components/ui/card'; import { Button } from '$lib/components/ui/button';</script>
<Card variant="elevated"> <CardHeader> <CardTitle>Card title</CardTitle> <CardDescription>A short supporting description.</CardDescription> </CardHeader> <CardContent>A card groups related content into a single surface.</CardContent> <CardFooter> <Button size="sm">Action</Button> </CardFooter></Card>Every part is optional and each is a plain element, so you can compose or skip them freely.
import "@nana-tec/ui-components/card";<nana-card style="max-width:22rem"> <nana-card-header> <nana-card-title>Card title</nana-card-title> <nana-card-description>A short supporting description.</nana-card-description> </nana-card-header> <nana-card-content>A card groups related content into a single surface.</nana-card-content> <nana-card-footer> <nana-button size="sm">Action</nana-button> </nana-card-footer></nana-card>Classes you pass to the React and Svelte components are merged with
tailwind-merge, so an override wins rather than fighting. See
Using Tailwind.
Variants
Section titled “Variants”The variant attribute sets the card’s surface treatment — default,
elevated, outlined, filled, or glass.
<nana-card variant="default" style="width: 12rem">
<nana-card-content>Default</nana-card-content>
</nana-card>
<nana-card variant="elevated" style="width: 12rem">
<nana-card-content>Elevated</nana-card-content>
</nana-card>
<nana-card variant="outlined" style="width: 12rem">
<nana-card-content>Outlined</nana-card-content>
</nana-card>
<nana-card variant="filled" style="width: 12rem">
<nana-card-content>Filled</nana-card-content>
</nana-card>
<nana-card variant="glass" style="width: 12rem">
<nana-card-content>Glass</nana-card-content>
</nana-card> Interactive
Section titled “Interactive”Add the interactive attribute to make the whole card a hoverable, focusable
target (e.g. a link card).
<nana-card variant="outlined" interactive style="width: 16rem">
<nana-card-header>
<nana-card-title>Interactive card</nana-card-title>
<nana-card-description>Hover or focus me</nana-card-description>
</nana-card-header>
<nana-card-content>Lifts on hover and shows a focus ring.</nana-card-content>
</nana-card> The React and Svelte props, read from the components’ own types:
Card
| Prop | Type | Default |
|---|---|---|
variant | CardVariant | 'default' |
Also accepts HTMLAttributes<HTMLDivElement>.
Card
| Prop | Type | Default |
|---|---|---|
variant | CardVariant | 'default' |
children | Snippet |
Also accepts Omit<
HTMLAttributes<HTMLDivElement>,
'class'
>.
The attribute names, events and CSS hooks below are the Web Components reference.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
interactive | interactive | boolean | false | Adds hover lift, pointer cursor and a focus ring for clickable cards. Composes with any variant. |
variant | variant | CardVariant | 'default' | Visual style |
Slots
| Slot | Description |
|---|---|
(default) | Card sub-sections (header, content, footer) |
CSS custom properties
| Property | Description |
|---|---|
--nana-card-bg | Background colour |
--nana-card-color | Text colour |
--nana-card-radius | Corner radius |
| Slot | Description |
|---|---|
(default) | Card sub-sections (header, content, footer) |
CSS Variables
Section titled “CSS Variables”| Variable | Description |
|---|---|
--nana-card-bg | Background colour |
--nana-card-color | Text colour |
--nana-card-radius | Corner radius |