Card example
import { Card } from "./ui/card";
import { Badge } from "./ui/badge";
import "./example.css";
export default function Example() {
return (
<Card
title="Coastal field notes"
description="Issue 08 · Winter edition"
action={<Badge tone="success">Ready for press</Badge>}
footer={<span>36 pages · 12 illustrations</span>}
>
<p>A collection of shoreline studies, tide tables and interviews with the working harbor.</p>
</Card>
);
}
@media screen and (prefers-reduced-motion: no-preference) {
#example button:is(.v-primary, .v-secondary):enabled {
transition: transform 120ms ease-out;
}
#example button:is(.v-primary, .v-secondary):enabled:active {
transform: scale(0.98);
}
}
@media (prefers-reduced-motion: reduce) {
#example button:is(.v-primary, .v-secondary):enabled:active {
transition: none;
transform: none;
}
}
* {
box-sizing: border-box;
}
:root {
--example-seed: var(--aster-primary);
--example-secondary-text: var(--aster-on-surface-subtle);
}
body {
--aster-primary: color-mix(in srgb, var(--example-seed) 84%, var(--aster-on-surface));
--aster-on-surface-subtle: color-mix(in srgb, var(--example-secondary-text) 84%, var(--aster-on-surface));
--aster-input-border: color-mix(in srgb, var(--aster-on-surface) 55%, var(--aster-surface));
margin: 0;
padding: clamp(0.8rem, 4vw, 1.5rem);
color: var(--aster-on-surface);
background: var(--aster-surface-muted);
font: 1rem/1.5 var(--aster-font-sans);
}
#example {
display: grid;
gap: 0.8rem;
min-width: 0;
align-content: start;
}
#example > button,
.sample > button {
justify-self: start;
}
.sample,
.tile {
background: var(--aster-surface);
border: 1px solid var(--aster-border);
border-radius: var(--aster-radius-lg);
}
.sample {
display: grid;
gap: 0.8rem;
padding: clamp(0.85rem, 3vw, 1.35rem);
box-shadow: var(--aster-shadow-xs);
min-width: 0;
}
.tile {
padding: 1rem;
min-width: 0;
}
h2,
h3,
p,
dl,
ul {
margin-block: 0;
}
h2,
h3 {
letter-spacing: -0.025em;
line-height: 1.2;
}
h2 {
font-size: 1.25rem;
}
h3 {
font-size: 1rem;
}
.sample > header,
.identity > div,
.receipt {
display: grid;
gap: 0.25rem;
}
.sample > header p,
.tile p,
small {
color: var(--aster-on-surface-muted);
}
small {
font-size: 0.82rem;
}
.split,
.actions,
.identity {
display: flex;
align-items: center;
gap: 0.65rem;
flex-wrap: wrap;
}
.split {
justify-content: space-between;
padding-block: 0.4rem;
border-bottom: 1px solid var(--aster-border);
}
.split:last-child {
border-bottom: 0;
}
.metric {
font-size: 2rem;
letter-spacing: -0.06em;
}
.facts {
display: grid;
grid-template-columns: max-content 1fr;
gap: 0.45rem 1rem;
}
.facts dt {
color: var(--aster-on-surface-muted);
}
.facts dd {
margin: 0;
font-weight: 600;
}
.type-sample {
font:
2rem/1.2 Georgia,
serif;
}
.listing {
padding-inline-start: 1.25rem;
}
.ink-strip {
height: 1.2rem;
background: var(--aster-primary);
border-radius: var(--aster-radius-sm);
}
.ink-proof {
display: grid;
gap: 0.15rem;
border-left: 0.6rem solid;
padding-left: 0.8rem;
}
.ink-proof strong {
font-size: 1.25rem;
letter-spacing: 0.06em;
}
.glyph {
display: inline-grid;
place-items: center;
width: 2rem;
height: 2rem;
border-radius: var(--aster-radius-sm);
color: var(--aster-on-primary-subtle);
background: var(--aster-primary-subtle);
}
.cover-box {
width: min(100%, 18rem);
}
.cover {
display: flex;
min-height: 7.5rem;
height: 100%;
padding: 1rem 1.25rem;
flex-direction: column;
justify-content: space-between;
gap: 1.6rem;
color: #fff;
background: repeating-linear-gradient(150deg, transparent 0 8px, #fff2 8px 9px), #204a48;
}
.cover strong {
font:
italic 2.45rem/1 Georgia,
serif;
}
.cover span {
font: 0.78rem var(--aster-font-mono);
}
.cover.grove {
background-color: #3d4b27;
}
.cover.dune {
background-color: #7c4428;
}
button:not([class]),
.entry {
font: inherit;
font-size: 0.875rem;
padding: 0.45rem 0.8rem;
border: 1px solid var(--aster-border-strong);
border-radius: var(--aster-radius-control);
background: var(--aster-surface);
color: var(--aster-on-surface);
}
button:not([class]) {
cursor: pointer;
font-weight: 600;
}
button:not([class]):hover:enabled {
background: var(--aster-primary-subtle);
}
button:disabled {
cursor: default;
}
:focus-visible {
outline: 2px solid var(--aster-primary);
outline-offset: 3px;
}
output:not(:empty) {
display: block;
color: var(--aster-on-primary-subtle);
font-weight: 600;
font-size: 0.9rem;
}
Site-owned component source and scoped styles
import './theme.css';
import { scope, type View } from '@fierst/aster';
const cardScope = scope`
:scope {
min-width: 0;
display: flex;
flex-direction: column;
border-radius: var(--aster-radius-lg);
color: var(--aster-on-surface);
overflow: hidden;
}
:scope.v-default {
background: var(--aster-surface);
border: 1px solid var(--aster-border);
box-shadow: var(--aster-shadow-xs);
}
:scope.v-elevated {
background: var(--aster-surface);
border: 1px solid var(--aster-border);
box-shadow: var(--aster-shadow-md);
}
:scope.v-muted {
background: var(--aster-surface-muted);
border: 1px solid var(--aster-border);
}
.card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
padding: 1.25rem 1.25rem 0;
}
.card-title {
margin: 0;
font-family: var(--aster-font-display);
font-size: 0.98rem;
font-weight: 600;
letter-spacing: -0.015em;
line-height: 1.35;
}
.card-desc {
margin: 0.25rem 0 0;
font-size: 0.84rem;
color: var(--aster-on-surface-muted);
line-height: 1.45;
}
.card-content {
padding: 1.25rem;
display: flex;
flex-direction: column;
gap: 0.9rem;
}
.card-footer {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 0.5rem;
padding: 0.85rem 1.25rem;
background: var(--aster-surface-muted);
border-top: 1px solid var(--aster-border);
}
`;
export type CardVariant = 'default' | 'elevated' | 'muted';
export function Card({
variant = 'default',
title,
description,
action,
footer,
class: extraClass,
children,
...rest
}: {
variant?: CardVariant;
title?: string;
description?: string;
action?: View;
footer?: View;
class?: string;
children?: View;
[key: string]: any;
}) {
return (
<section {...rest} class={[cardScope, `v-${variant}`, extraClass].filter(Boolean).join(' ')}>
{title || description || action ? (
<header class="card-header">
<div>
{title ? <h2 class="card-title">{title}</h2> : null}
{description ? <p class="card-desc">{description}</p> : null}
</div>
{action ?? null}
</header>
) : null}
<div class="card-content">{children}</div>
{footer ? <footer class="card-footer">{footer}</footer> : null}
</section>
);
}
A card, a button and a tooltip each use different color roles. The card supplies a reading surface, the button needs a visible focus state, and the tooltip needs to stand out against the surface underneath. In the example above, open Code + CSS to see which decisions belong to the card and which belong to the page.
Choose roles before colors
Start a panel with --aster-surface and --aster-on-surface. Use semantic colors for a state such as success or danger, and give the state a text label so the reader can identify it without color. Inspect the badge and tooltip examples to see the foreground, background and border roles they use. Badge · Tooltip.
Change one seed across controls
The stylesheet provides six presets. Zinc gives the primary action a neutral color. The chromatic presets use a hue and chroma to derive related roles where the browser supports OKLCH. The shared stylesheet also defines fallback values. To inspect the change, switch the seed in the theme example and compare the badge before and after. The theme reference includes the controller and the token names. Try the theme cookbook · Inspect the theme source.
Check geometry, focus and motion
Use the controller's radius and density settings when controls across a page should change together. Tab through a button group, press Space to activate an enabled button and inspect its focus ring in each mode you support. The shared styles include media queries for coarse pointers, increased contrast and reduced motion. Check a customized component's scoped styles as well as the global theme. Exercise the button group · Inspect the shared stylesheet.
Separate a decision from its effects
An approval card can show who needs to act and report the choice through a callback. A workflow graph can show a review changing from waiting to done. In a production app, the caller would send the decision to a server and use the server's result to update the graph. The examples let you inspect those two pieces independently. Try ApprovalCard · Try WorkflowGraph.