Card
A container that groups related content and actions. Same markup and props in every style: switch the style in the header to see it change.
Basic
Header, body and footer. Every part is optional, and the spacing follows Customize → Density.
Team plan
Everything in Free, plus shared workspaces.
Invite up to 10 people, share components and keep one theme for the whole team.
<div class="vin-card" style="width: 100%; max-width: 360px">
<div class="vin-card__header">
<h3 class="vin-card__title">Team plan</h3>
<p class="vin-card__desc">Everything in Free, plus shared workspaces.</p>
</div>
<div class="vin-card__body">
<p>Invite up to 10 people, share components and keep one theme for the whole team.</p>
</div>
<div class="vin-card__footer">
<button type="button" class="vin-btn">Upgrade</button>
<button type="button" class="vin-btn vin-btn--ghost">Compare plans</button>
</div>
</div>Team plan
Everything in Free, plus shared workspaces.
Invite up to 10 people, share components and keep one theme for the whole team.
import { Card, CardHeader, CardTitle, CardDescription, CardBody, CardFooter } from "@/components/vin/card";
import { Button } from "@/components/vin/button";
export function CardBasic() {
return (
<Card style={{ width: "100%", maxWidth: 360 }}>
<CardHeader>
<CardTitle>Team plan</CardTitle>
<CardDescription>Everything in Free, plus shared workspaces.</CardDescription>
</CardHeader>
<CardBody>
<p>Invite up to 10 people, share components and keep one theme for the whole team.</p>
</CardBody>
<CardFooter>
<Button>Upgrade</Button>
<Button variant="ghost">Compare plans</Button>
</CardFooter>
</Card>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Card, { CardHeader, CardTitle, CardDescription, CardBody, CardFooter } from "@/components/vin/card.vue";
import Button from "@/components/vin/button.vue";
</script>
<template>
<Card style="width: 100%; max-width: 360px">
<CardHeader>
<CardTitle>Team plan</CardTitle>
<CardDescription>Everything in Free, plus shared workspaces.</CardDescription>
</CardHeader>
<CardBody>
<p>Invite up to 10 people, share components and keep one theme for the whole team.</p>
</CardBody>
<CardFooter>
<Button>Upgrade</Button>
<Button variant="ghost">Compare plans</Button>
</CardFooter>
</Card>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Card from "$lib/components/vin/card.svelte";
import CardHeader from "$lib/components/vin/card-header.svelte";
import CardTitle from "$lib/components/vin/card-title.svelte";
import CardDescription from "$lib/components/vin/card-description.svelte";
import CardBody from "$lib/components/vin/card-body.svelte";
import CardFooter from "$lib/components/vin/card-footer.svelte";
import Button from "$lib/components/vin/button.svelte";
</script>
<Card style="width: 100%; max-width: 360px">
<CardHeader>
<CardTitle>Team plan</CardTitle>
<CardDescription>Everything in Free, plus shared workspaces.</CardDescription>
</CardHeader>
<CardBody>
<p>Invite up to 10 people, share components and keep one theme for the whole team.</p>
</CardBody>
<CardFooter>
<Button>Upgrade</Button>
<Button variant="ghost">Compare plans</Button>
</CardFooter>
</Card>Stat card
A big number with a trend badge: the building block of dashboards.
Monthly visitors
48,210
<div class="vin-card" style="width: 100%; max-width: 280px">
<div class="vin-card__header">
<p class="vin-card__desc">Monthly visitors</p>
<h3 class="vin-card__title" style="font-size: 28px">48,210</h3>
</div>
<div class="vin-card__footer">
<span class="vin-badge vin-badge--success">+12.5%</span>
<p class="vin-card__desc">vs last month</p>
</div>
</div>Monthly visitors
48,210
import { Card, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/vin/card";
import { Badge } from "@/components/vin/badge";
export function CardStat() {
return (
<Card style={{ width: "100%", maxWidth: 280 }}>
<CardHeader>
<CardDescription>Monthly visitors</CardDescription>
<CardTitle style={{ fontSize: 28 }}>48,210</CardTitle>
</CardHeader>
<CardFooter>
<Badge variant="success">+12.5%</Badge>
<CardDescription>vs last month</CardDescription>
</CardFooter>
</Card>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Card, { CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/vin/card.vue";
import Badge from "@/components/vin/badge.vue";
</script>
<template>
<Card style="width: 100%; max-width: 280px">
<CardHeader>
<CardDescription>Monthly visitors</CardDescription>
<CardTitle style="font-size: 28px">48,210</CardTitle>
</CardHeader>
<CardFooter>
<Badge variant="success">+12.5%</Badge>
<CardDescription>vs last month</CardDescription>
</CardFooter>
</Card>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Card from "$lib/components/vin/card.svelte";
import CardHeader from "$lib/components/vin/card-header.svelte";
import CardTitle from "$lib/components/vin/card-title.svelte";
import CardDescription from "$lib/components/vin/card-description.svelte";
import CardFooter from "$lib/components/vin/card-footer.svelte";
import Badge from "$lib/components/vin/badge.svelte";
</script>
<Card style="width: 100%; max-width: 280px">
<CardHeader>
<CardDescription>Monthly visitors</CardDescription>
<CardTitle style="font-size: 28px">48,210</CardTitle>
</CardHeader>
<CardFooter>
<Badge variant="success">+12.5%</Badge>
<CardDescription>vs last month</CardDescription>
</CardFooter>
</Card>With a form
Cards hold form fields and actions without any extra CSS.
New project
You can change these later.
<div class="vin-card" style="width: 100%; max-width: 360px">
<div class="vin-card__header">
<h3 class="vin-card__title">New project</h3>
<p class="vin-card__desc">You can change these later.</p>
</div>
<div class="vin-card__body">
<div class="vin-field">
<label class="vin-label" for="project-name">Project name</label>
<input id="project-name" class="vin-input" placeholder="My app">
</div>
</div>
<div class="vin-card__footer">
<button type="button" class="vin-btn">Create</button>
<button type="button" class="vin-btn vin-btn--outline">Cancel</button>
</div>
</div>New project
You can change these later.
import { Card, CardHeader, CardTitle, CardDescription, CardBody, CardFooter } from "@/components/vin/card";
import { Field } from "@/components/vin/input";
import { Button } from "@/components/vin/button";
export function CardForm() {
return (
<Card style={{ width: "100%", maxWidth: 360 }}>
<CardHeader>
<CardTitle>New project</CardTitle>
<CardDescription>You can change these later.</CardDescription>
</CardHeader>
<CardBody>
<Field label="Project name" placeholder="My app" />
</CardBody>
<CardFooter>
<Button>Create</Button>
<Button variant="outline">Cancel</Button>
</CardFooter>
</Card>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Card, { CardHeader, CardTitle, CardDescription, CardBody, CardFooter } from "@/components/vin/card.vue";
import Button from "@/components/vin/button.vue";
import Field from "@/components/vin/input.vue";
</script>
<template>
<Card style="width: 100%; max-width: 360px">
<CardHeader>
<CardTitle>New project</CardTitle>
<CardDescription>You can change these later.</CardDescription>
</CardHeader>
<CardBody>
<Field label="Project name" placeholder="My app" />
</CardBody>
<CardFooter>
<Button>Create</Button>
<Button variant="outline">Cancel</Button>
</CardFooter>
</Card>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Card from "$lib/components/vin/card.svelte";
import CardHeader from "$lib/components/vin/card-header.svelte";
import CardTitle from "$lib/components/vin/card-title.svelte";
import CardDescription from "$lib/components/vin/card-description.svelte";
import CardBody from "$lib/components/vin/card-body.svelte";
import CardFooter from "$lib/components/vin/card-footer.svelte";
import Field from "$lib/components/vin/input-field.svelte";
import Button from "$lib/components/vin/button.svelte";
</script>
<Card style="width: 100%; max-width: 360px">
<CardHeader>
<CardTitle>New project</CardTitle>
<CardDescription>You can change these later.</CardDescription>
</CardHeader>
<CardBody>
<Field label="Project name" placeholder="My app" />
</CardBody>
<CardFooter>
<Button>Create</Button>
<Button variant="outline">Cancel</Button>
</CardFooter>
</Card>Installation
React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:
npx @vinish/ui add cardimport { Card, CardHeader, CardTitle, CardDescription, CardBody, CardFooter } from "@/components/vin/card";import Card, { CardHeader, CardTitle, CardDescription, CardBody, CardFooter } from "@/components/vin/card.vue";import Card from "$lib/components/vin/card.svelte";
import CardBody from "$lib/components/vin/card-body.svelte";
import CardDescription from "$lib/components/vin/card-description.svelte";
import CardFooter from "$lib/components/vin/card-footer.svelte";
import CardHeader from "$lib/components/vin/card-header.svelte";
import CardTitle from "$lib/components/vin/card-title.svelte";The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.
Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.
API
From spec/card.json, which every framework version is tested against.
| Prop | Values | Default | In HTML |
|---|---|---|---|
as (CardTitle)Heading level for the title, so it fits your page outline. | h2h3h4p | h3 | the tag of .vin-card__title |
Parts
| React, Vue, Svelte | HTML classes |
|---|---|
<Card><CardHeader><CardTitle><CardDescription><CardBody><CardFooter> | .vin-card.vin-card__header.vin-card__title.vin-card__desc.vin-card__body.vin-card__footer |
Accessibility
- The title is a real heading (h3 by default), so it appears in the page outline. Pick the level that fits your page.
- A card is a plain container: put links and buttons inside it rather than making the whole card clickable.
- Text and description meet 4.5:1 contrast in every style and mode.
Customize
Saved in this browser. Style and accent are in the header.