Button example
import { signal } from "@fierst/aster";
import { Button, ButtonGroup } from "./ui/button";
import "./example.css";
export default function* Example() {
const seats = signal(0);
for (;;)
yield (
<section class="sample">
<header>
<h2>Workshop reservation</h2>
<p>Reserve up to four seats for the letterpress session.</p>
</header>
<ButtonGroup label="Adjust reservation">
<Button
variant="primary"
disabled={seats() === 4}
onClick={() => seats.update((current) => current + 1)}
>
Add seat · {seats()}
</Button>
<Button disabled={!seats()} onClick={() => seats.update((current) => current - 1)}>
Remove seat
</Button>
</ButtonGroup>
<output>{seats() ? `${seats()} of 4 seats reserved` : "No seats reserved"}</output>
</section>
);
}
@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 { LoaderCircle } from '@lucide/icons';
import { scope, type View } from '@fierst/aster';
import { Icon } from './icon';
const btnScope = scope`
:scope {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.45rem;
font-family: var(--aster-font-sans);
font-weight: 500;
line-height: 1;
border-radius: var(--aster-radius-control);
border: 1px solid transparent;
cursor: pointer;
user-select: none;
text-decoration: none;
white-space: nowrap;
touch-action: manipulation;
transition:
background-color var(--aster-dur-fast) var(--aster-ease-standard),
border-color var(--aster-dur-fast) var(--aster-ease-standard),
color var(--aster-dur-fast) var(--aster-ease-standard),
box-shadow var(--aster-dur-fast) var(--aster-ease-standard),
transform var(--aster-dur-fast) var(--aster-ease-motion);
}
:scope:focus-visible { outline: none; box-shadow: var(--aster-focus-ring); }
:scope:active:not(:disabled) { transform: scale(0.98); }
:scope:disabled { opacity: 0.5; pointer-events: none; }
/* Proven shadcn / TailwindUI control heights */
:scope.sz-sm { height: var(--aster-control-sm); padding: 0 0.75rem; font-size: 0.8125rem; }
:scope.sz-md { height: var(--aster-control-md); padding: 0 1rem; font-size: 0.875rem; }
:scope.sz-lg { height: var(--aster-control-lg); padding: 0 1.25rem; font-size: 0.9375rem; }
:scope.sz-icon { height: var(--aster-control-md); width: var(--aster-control-md); padding: 0; }
:scope.v-primary {
background: var(--aster-primary);
color: var(--aster-on-primary);
box-shadow: var(--aster-shadow-xs);
}
:scope.v-primary:hover { background: var(--aster-primary-hover); }
:scope.v-secondary {
background: var(--aster-surface-muted);
color: var(--aster-on-surface);
}
:scope.v-secondary:hover { background: var(--aster-surface-accent); }
:scope.v-outline {
background: var(--aster-surface);
color: var(--aster-on-surface);
border-color: var(--aster-input-border);
box-shadow: var(--aster-shadow-xs);
}
:scope.v-outline:hover {
background: var(--aster-surface-muted);
border-color: var(--aster-border-strong);
}
:scope.v-ghost {
background: transparent;
color: var(--aster-on-surface);
}
:scope.v-ghost:hover { background: var(--aster-surface-muted); }
:scope.v-destructive {
background: var(--aster-danger);
color: var(--aster-on-danger);
box-shadow: var(--aster-shadow-xs);
}
:scope.v-destructive:hover { background: var(--aster-danger-hover); }
:scope.v-link {
background: transparent;
color: var(--aster-primary);
padding-left: 0.25rem;
padding-right: 0.25rem;
}
:scope.v-link:hover { text-decoration: underline; text-underline-offset: 4px; }
`;
const groupScope = scope`
:scope {
display: inline-flex;
align-items: center;
max-width: 100%;
overflow-x: auto;
scrollbar-width: none;
}
:scope::-webkit-scrollbar { display: none; }
:scope > button:not(:first-child) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
margin-left: -1px;
}
:scope > button:not(:last-child) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
:scope > button:focus-visible { position: relative; z-index: 1; }
`;
export type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive' | 'link';
export type ButtonSize = 'sm' | 'md' | 'lg' | 'icon';
export interface ButtonProps {
variant?: ButtonVariant;
size?: ButtonSize;
loading?: boolean;
disabled?: boolean;
type?: 'button' | 'submit' | 'reset';
class?: string;
children?: View;
[key: string]: any;
}
export function Button({
variant = 'outline',
size = 'md',
loading = false,
disabled = false,
type = 'button',
class: extraClass,
children,
...rest
}: ButtonProps) {
const cls = [btnScope, `v-${variant}`, `sz-${size}`, extraClass].filter(Boolean).join(' ');
return (
<button {...rest} type={type} class={cls} disabled={disabled || loading} aria-busy={loading}>
{loading ? <Icon icon={LoaderCircle} size={15} spin /> : null}
{children}
</button>
);
}
export function ButtonGroup(props: { class?: string; children?: View; label?: string }) {
return (
<div
role="group"
aria-label={props.label}
class={[groupScope, props.class].filter(Boolean).join(' ')}
>
{props.children}
</div>
);
}
The registry installer copies TSX, component styles and dependency files into your project. Import the local module, commit it with the feature that uses it, and review future upstream changes alongside your edits.
Install a button and its dependencies
npx @fierst/ui@1.0.2 add button --dir src/uiThe button manifest lists two registry dependencies, theme and icon, plus the npm package @lucide/icons. Open its files array to see the button source and target path. The installer copies the local helpers, then prints the npm command for the package dependency. Keep the copied files together so the button’s relative imports resolve.
Choose what to edit
Use a public prop for a choice the component already models, such as a button variant. Use theme tokens for a decision shared by many components, such as control radius. Edit the owned TSX when the markup or interaction itself needs to change. In Code + CSS, compare the button’s use in the example with the site-owned component source. In the latter, find the CSS selector for the primary variant. Inspect Button and ButtonGroup.
Review an update
To compare your copy against this release, run npx @fierst/ui@1.0.2 add button --dir src/ui-review from the project root. Compare src/ui-review with src/ui, including theme.css and shared helpers. For a future release, substitute that release’s version in the command. Merge the changes you want, then exercise focus, keyboard activation and any modified event callbacks. The --force option replaces matching files, so a clean diff is particularly valuable.