Actions
One button pair, icon controls, and one link look.
Variants
One pair: the ink primary and the tonal secondary. A view has one primary. Danger is for a button that destroys something when pressed, usually inside a confirmation; a button that only opens that confirmation stays secondary.
Code
<Button variant="primary">Begin session</Button>
<Button>View history</Button>
<Button variant="danger" icon={<Icon icon={Trash2} size="small" />}>
Delete account
</Button>
Sizes
Code
<Button size="small">Small</Button>
<Button>Regular</Button>
<Button size="large">Large</Button>
Large buttons carry a single task, such as signing in. Small buttons sit in dense rows, toolbars and table cells.
States
A button lifts 1px under a pointer and settles when pressed. A disabled button keeps its resting color and does not move, and says why nearby, because a disabled control cannot explain itself. Loading keeps the label for width, shows a spinner in its place and announces that it is busy, and it always ends.
Code
"use client";
import { useEffect, useState } from "react";
import { Button, Cluster, FormStatus } from "@oxidase/ui";
/**
* A button that is busy for a moment after it is pressed. Loading always ends:
* a busy state that never resolves is a failure, not a state. Nothing is saved.
*/
export function LoadingDemo() {
const [state, setState] = useState<"idle" | "saving" | "saved">("idle");
useEffect(() => {
if (state !== "saving") return;
const timer = window.setTimeout(() => setState("saved"), 1600);
return () => window.clearTimeout(timer);
}, [state]);
return (
<Cluster gap="s12">
<Button variant="primary" loading={state === "saving"} onClick={() => setState("saving")}>
Save changes
</Button>
<FormStatus>{state === "saved" ? "Saved. Nothing left this page." : ""}</FormStatus>
</Cluster>
);
}Code
<Button disabled>Export</Button>
<Button pressed>Show hints</Button>
Text link
The one link look: ink at weight 560 with a quiet underline that draws in fully under a pointer or focus. For links in running text and for a single onward step.
Read the voice guide before writing an error.
See where you standCode
<Text tone="secondary">
Read the
<TextLink href="/design/patterns/voice" component={i}>
voice guide
</TextLink>
before writing an error.
</Text>
<TextLink href="/design/components/data" component={i}>
See where you stand
</TextLink>
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | None | The destination. |
component | ElementType | "a" | The link element, such as next/link. |
xstyle | LayoutStyle | None | Placement only. |
Choosing an action
- Does it change something here? A button. Does it go somewhere? A link, shaped as a button only when it starts a task.
- One primary action per view. If two actions compete, the page needs a different structure, not two filled buttons.
- Label actions with a verb and its object: Save changes, Begin session, Revoke this device. Avoid OK and Submit.
- Destructive actions ask first, with a confirmation that names what will be lost.
Do
A verb and its object, then a tonal way out.
Avoid
Vague labels and two filled buttons: neither says what happens.