Button

Runs a command, with pending, disabled and glass states.

  • Composed
  • Liquid Glass on iOS 26
  • In the first release
import { Button, buttonPrimitive } from "nitro-ui-sdk/button";
HeroUI Native
Button
Expo UI
Button
  • Button example screen, light appearance
    Light
  • Button example screen, dark appearance
    Dark
  • Button example screen, liquid glass appearance
    Liquid Glass
On this page

A labeled action: save, continue, delete. It presses with a native scale and a light haptic, shows a spinner while its async work runs, and has glass variants for floating toolbars and media. Use IconButton when the action has only a glyph, LinkButton for inline text links, ToggleButton for an on/off state and FloatingActionButton for the screen’s primary floating action.

Anatomy

import { Button } from "nitro-ui-sdk/button";

export function Anatomy() {
  return (
    <Button.Root label="Share" onPress={() => {}}>
      <Button.Leading symbol="square.and.arrow.up" />
      <Button.Label />
      <Button.Trailing symbol="chevron.right" />
    </Button.Root>
  );
}
Part Description
Button.Root The native pressable host. It owns the name, the press, the haptic, the surface and the feedback.
Button.Leading A glyph before the label. While busy the spinner takes its place, so the label never moves.
Button.Label The visible title. Defaults to the root’s label.
Button.Trailing A glyph after the label, such as chevron.right.
Button.BusyIndicator The platform spinner, rendered only while busy. Use it when there is no leading glyph.

Without children the root renders Leading (when icon is set) or BusyIndicator, then Label, then Trailing (when trailingIcon is set).

Usage

import { Button } from "nitro-ui-sdk/button";

export function Save({ save }: { save: () => Promise<void> }) {
  return <Button.Root label="Save" busyLabel="Saving" icon="checkmark" onPress={save} />;
}

Variants and sizes

Variant Look
primary (default) Solid accent fill, accentForeground content.
secondary accentSoft fill, accentSoftForeground content.
tertiary Neutral default fill.
outline Transparent with a border hairline.
ghost Transparent action with no border.
danger Solid danger fill for destructive actions.
danger-soft dangerSoft fill for a quieter destructive action.
glass Liquid Glass; falls back to the default fill.
glass-prominent Accent-tinted Liquid Glass; falls back to a solid accent fill.
Size Height (tokens.control) Text Glyph
sm 36 subheadline 15
md (default) 44 callout 17
lg 52 headline 19

Every size keeps a touch area of at least 44 × 44 pt (iOS) without changing its layout. fullWidth stretches the button across its container.

States

  • Disabled: disabled dims the button to opacity.disabled and refuses presses from touch, the agent and the API.
  • Busy: an onPress that returns a promise keeps the button busy until it settles; busy sets it from outside. A busy button refuses further presses at once, even before it re-renders. The label and the spoken name stay the same; busyLabel is spoken as the value.
  • Pressed: the surface scales to motion.pressedScale and springs back. Live glass uses the system press effect. Reduce Motion dims the surface instantly.
  • Failure: a rejected promise ends the busy state. The button never reports the error; the handler that returned the promise shows it.

Liquid Glass

glass and glass-prominent draw an interactive MaterialView when the theme has glass on, the OS supports Liquid Glass (iOS 26) and Reduce Transparency is off. The glass grows and shimmers under the finger, so the kit adds no scale of its own. Otherwise the button draws its opaque fallback (default or accent fill) and scales like a solid variant. Put glass buttons over color: media, maps, a GlassSurface toolbar.

import { View } from "nitro-ui-renderer";
import { Button } from "nitro-ui-sdk/button";

export function PlayerControls() {
  return (
    <View layout={{ flexDirection: "row", gap: 12 }}>
      <Button.Root label="Play" icon="play.fill" variant="glass-prominent" onPress={() => {}} />
      <Button.Root label="Queue" icon="list.bullet" variant="glass" onPress={() => {}} />
    </View>
  );
}

Props

Button.Root

Prop Type Default Description
label string required The accessible name and the default visible title.
onPress (details: ActionDetails) => void | PromiseLike<unknown> required Runs on every accepted press. Returning a promise shows the busy state. details.source is user, agent or api.
variant ButtonVariant "primary" See Variants.
size "sm" | "md" | "lg" "md" See Sizes.
icon string — SF Symbol before the label.
trailingIcon string — SF Symbol after the label.
fullWidth boolean false Stretches across the container.
disabled boolean false Refuses every press.
busy boolean false Shows the pending state from outside.
busyLabel string — Spoken after the name while busy.
hint string — Accessibility hint.
haptic "light" | "medium" | "heavy" | "none" "light" Impact felt when a touch presses. Agent and API presses stay silent.
api Controller<ButtonActions> — Controller from buttonPrimitive.createApi().
agentId string — Stable identity for the agent registry.
confirm { message, approveLabel, cancelLabel } — Localized prompt shown before an agent presses. Required to expose press on destructive variants.
styles ButtonStyles — Per-part style resolvers.
layout LayoutProps — Layout of the host.
children ReactNode — Custom anatomy.

Button.Leading, Button.Trailing

Prop Type Default Description
symbol string — SF Symbol name.
fallback ImageLoader — Image for Android and missing symbols.
children ReactNode — Custom glyph instead of the symbol.
part ButtonPart the slot Style the element as another part.

Button.Label

Prop Type Default Description
children string root’s label Visible title.
part ButtonPart "label" Selects the style resolver.

Button.BusyIndicator

Prop Type Default Description
children ReactNode platform spinner Content to show while busy.
part ButtonPart "busyIndicator" Selects the style resolver.

Controller API

import { useState } from "react";
import { Button, buttonPrimitive } from "nitro-ui-sdk/button";

export function Submit({ submit }: { submit: () => Promise<void> }) {
  const [api] = useState(buttonPrimitive.createApi);
  return (
    <>
      <Button.Root label="Submit" api={api} onPress={submit} />
      <Button.Root label="Submit from code" variant="outline" onPress={() => void api.current?.press()} />
    </>
  );
}
Action Signature Result
press (source?: ActionSource) => ActionStatus accepted, disabled (disabled or busy) or refused (the handler called preventDefault()).

api.current is undefined before mount and after unmount.

Styles

import { Button, type ButtonStyles } from "nitro-ui-sdk/button";

const styles: ButtonStyles = {
  root: ({ tokens, state }) => ({ style: { cornerRadius: tokens.radius.control, opacity: state.busy ? 0.8 : 1 } }),
  label: ({ tokens }) => ({ text: { fontWeight: "bold", color: tokens.colors.accentForeground } }),
};

export function Squared() {
  return <Button.Root label="Continue" styles={styles} onPress={() => {}} />;
}

Parts: root, leading, label, trailing, busyIndicator. The resolver receives { tokens, variant, size, state } with state: { disabled: boolean; busy: boolean }. Glyph parts read text.color and text.fontSize for the symbol. Resolution is memoized per tokens, variant, size and state.

Accessibility

  • One accessibility element with the button trait, named by label. The content inside is not read separately.
  • Disabled and busy add notEnabled (“dimmed”). While busy, busyLabel is the value: “Save, Saving, dimmed, button”.
  • VoiceOver activation, Voice Control and Full Keyboard Access go through the same controller as touch.
  • The touch area is at least 44 × 44 pt.
  • Reduce Motion replaces the scale with an instant dim.

Agent API

Action Arguments Notes
press none Same controller as touch. With confirm, the person approves first. Hidden while disabled or busy.

danger and danger-soft expose press only with a localized confirm prompt. The button still appears in the snapshot with its role, name and state. Touch and controller presses work as usual.

The entry has component: "Button", role: "button", name: label and state: { disabled, busy }.

Platform notes

iOS Android
Host KitPressable: a native accessibility element with a gesture tracker (32 pt slack, cancels on scroll, never delays touches so interactive glass still reacts). PressableGroup (ViewGroup) with click and long-click listeners and an accessibility delegate (Button class).
Feedback UIViewPropertyAnimator spring and timing, started from JS on the main thread. The same animate/animateSpring calls, run by the renderer’s Android views.
Hit area Grows to 44 pt with point(inside:). The host reserves at least 44 display-independent pixels on each axis.
Glass Liquid Glass on iOS 26, opaque fallback otherwise. Opaque fallback.
Haptics UIImpactFeedbackGenerator. HapticFeedbackConstants.
Verification Unit, type and iOS harness tests. Kotlin is written to compile but not built here: the Android NDK is not installed on this machine.