Skip to content
oxidaseSign in

Actions

One button pair, icon controls, and one link look.

Button

A button performs an action on this page. It defaults to type="button", so a button inside a form never submits by accident; pass type="submit" for the one that should. Put it beside the object it changes rather than in a distant toolbar.

Code
<Button variant="primary">Save changes</Button>
<Button>Cancel</Button>
PropTypeDefaultDescription
variant"primary" | "secondary" | "danger""secondary"Primary is the one ink action in a view, secondary the tonal one beside it. Danger performs a destructive action itself.
size"small" | "regular" | "large""regular"32, 44 and 48 pixels tall. Regular follows the density register, so it is 32 pixels in the console.
iconReactNodeNoneA leading glyph. Replaced by a spinner while loading, so the width holds.
iconEndReactNodeNoneA trailing glyph, such as an arrow for a step forward. It steps forward on hover.
loadingbooleanfalseKeeps the width and focus and sets aria-busy while an action runs.
pressedbooleanNoneMakes the button a toggle, sets aria-pressed and fills it with ink while on.
xstyleLayoutStyleNonePlacement and size only: margins, grid and flex placement, width.

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>

Icon button

A round control for a well-known action: a bare glyph by default, a tonal circle as secondary. The label is required: it becomes the accessible name and the tooltip, and it names the object, such as "Close session details" rather than "Close".

Code
<IconButton
  label="Close session details"
  icon={<Icon icon={X} size="small" />}
/>
<IconButton
  label="More actions for this session"
  icon={<Icon icon={Ellipsis} size="small" />}
  variant="secondary"
/>
<IconButton
  label="Download the session export"
  icon={<Icon icon={Download} size="small" />}
  variant="secondary"
  size="small"
/>
PropTypeDefaultDescription
labelstringNoneRequired. The accessible name and tooltip.
iconReactNodeNoneThe glyph, usually an Icon at the small size.
variant"primary" | "secondary" | "danger"NoneUnset, a bare glyph; secondary gives it the tonal circle.
size"small" | "regular" | "large""regular"A circle of the matching button height.
pressedbooleanNoneA toggle, with aria-pressed.

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.