Documentation

Button

The action: a button in five looks (primary, secondary, outline, ghost, danger), three sizes and two shapes.

Web + MobileStableActions

Web and mobile — the same component for React and React Native. Stable: its API only changes in a major version.

When to use

  • To run an action: submit a form, open a dialog, start an upload, save a draft.
  • One primary button for the main action of a view; secondary, outline or ghost for the others.
  • IconButton for a compact action shown by its icon alone (close, add, more), with a label for its name.

When not to use

  • To go to another page: use a link (asChild with your router's <Link> keeps the button look).
  • To turn a setting on or off, with an immediate effect.Use instead: Switch
  • For a destructive action that needs a second press to confirm, in place.Use instead: Confirm button
  • To choose one option among several, or filter a list.Use instead: Chip

Installation

Install

npm install @krizaka/ui@beta @krizaka/tailwind@beta @krizaka/tokens@beta tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Import

import { Button, IconButton } from "@krizaka/ui/button";

Examples

Primary

The main action of a view: the accent.

Secondary

The default: a raised surface, for the other actions.

Outline

A lighter action next to a primary one.

Ghost

In toolbars and dense lists: no frame until hovered.

Danger

A destructive action: the border and the tint carry the danger, the label stays legible in both themes.

Sizes

sm, md (default) and lg.

Pill

shape="pill": fully rounded.

Disabled

Not available yet: out of the tab order.

Loading

While the action runs: disabled, aria-busy, data-loading.

asChild renders your <a> (or router link) with the button's look.

Icon button

IconButton: a square button holding an icon; label is its accessible name.

Props

Button

PropTypeDefaultDescription
asChildboolean—Renders the child (e.g. a <Link>) instead of the <button>, with props, classes and ref merged.
loadingboolean—Disables and signals the wait (aria-busy, data-loading) — the product adds a spinner if it wants one.
shape"rounded" | "pill"roundedrounded · pill.
size"icon" | "sm" | "md" | "lg"mdsm · md · lg, or icon (a square).
variant"danger" | "primary" | "secondary" | "outline" | "ghost"secondaryThe look: primary (the accent), secondary (a raised surface), outline, ghost, danger.

IconButton

An icon-only button: label is required, it is its accessible name.

PropTypeDefaultDescription
labelrequiredstring—The accessible name (and tooltip) of the button — required, passed translated.
asChildboolean—Renders the child (e.g. a <Link>) instead of the <button>, with props, classes and ref merged.
loadingboolean—Disables and signals the wait (aria-busy, data-loading) — the product adds a spinner if it wants one.
shape"rounded" | "pill"roundedrounded · pill.
size"icon" | "sm" | "md" | "lg"iconsm · md · lg, or icon (a square).
variant"danger" | "primary" | "secondary" | "outline" | "ghost"secondaryThe look: primary (the accent), secondary (a raised surface), outline, ghost, danger.

Accessibility

  • A native <button type="button">: the role, the focus and the keyboard come from the platform.
  • IconButton requires label: it becomes the aria-label of a button that shows no text.
  • loading sets aria-busy and disables the button; disabled keeps it out of the tab order.

Keyboard

KeysAction
Enter / SpaceRuns the action.
TabMoves the focus to the next control; the focus ring uses --kz-ring.

Best practices

  • Name the action with a verb: “Save”, “Send the invitation” — not “OK” or “Yes”.
  • One primary per view; the danger variant only for what destroys or cannot be undone.
  • loading while the action runs: the button is disabled and says it is busy; keep its width by keeping its words short.
  • Style a link without the component with buttonVariants({ variant, size }).

Generated from the code of @krizaka/ui 2.0.0-beta.6: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page