RUI · Native components

Button

The primary action control. A row of actions where one action is committed.

23 storiesRendered directly from RUI
Native preview

Overview

No iframe

The component is rendered directly from the RUI source. Choose a story to inspect its states; the generated reference stays in Storybook.

Native RUI story

All Variants

All four action roles in one row: secondary, primary, danger and ghost.

components/Button/Button.stories.tsx

Rendered directly from the RUI component source. Storybook remains the full reference.

Usage

The primary action control. A row of actions where one action is committed.

  • secondary — the everyday action (default, glass).
  • primary — accent-tinted; use one per view / region.
  • ghost — no fill; low emphasis (toolbars, inline).
  • danger — destructive; never the default action.

States & props

  • floating — sits over a picture or another surface (its own island). Never nest a floating button in a recessed surface.
  • glass={false} — flat fill; active — pressed/toggled; loading / success — in-place feedback that keeps the width.
  • size xs–xl, leftIcon/rightIcon, color / backgroundColor, leftFlat/rightFlat (join adjacent buttons), insetFocus.

Rules

  • Do keep labels short and verb-first ("Save changes").
  • Do give icon-only buttons an accessible name (aria-label).
  • Don't use danger for non-destructive actions.
  • Don't put more than one primary in a group.
  • Native DOM props (onClick, type, aria-*…) are forwarded.

Specs

Variants

VariantRole
secondaryEveryday action; the default glass control.
primaryAccent-tinted call to action; use one per view or region.
ghostNo fill; low emphasis in toolbars and inline contexts.
dangerDestructive action; never the default action.

Sizes

SizeHeightUse
xs26 pxDense desktop toolbars.
sm30 pxCompact rows and secondary controls.
md36 pxDefault size.
lg44 pxProminent actions and touch surfaces.
xl52 pxLarge surfaces and onboarding.

States

StateBehavior
floatingSits over a picture or another surface; treat it as its own island.
glass={false}Flat fill without the glass material.
activePersistent pressed or selected state.
loadingShows a spinner, sets aria-busy and disables the button.
successIn-place success feedback that keeps the button width.
disabled50% opacity and no pointer interaction.

Props

PropTypeDescription
variant'primary' | 'secondary' | 'ghost' | 'danger'Visual role of the action.
size'xs' | 'sm' | 'md' | 'lg' | 'xl'Shared control size scale.
colorstringOverrides the accent for this element only.
backgroundColorstringExplicit fill colour, independent of color.
leftIcon / rightIconReactNodeOptional leading or trailing icon.
loadingbooleanSpinner, aria-busy and disabled interaction.
successbooleanIn-place success state.
activebooleanPersistent pressed or selected state.
floatingbooleanElement state for controls over a background.
glassbooleanSet false for a flat fill.
leftFlat / rightFlatbooleanFlat corners for joined actions.
noSidePaddingbooleanRemoves horizontal padding for icon-only content.
insetFocusbooleanDraws the focus ring inside the button.
native propsbutton / anchor propsonClick, type, aria-* and other native props are forwarded.

Accessibility

  • Button renders a native button; ButtonLink renders an anchor with the same visual contract.
  • Keep a visible label. Icon-only actions need an aria-label and enough spacing.
  • loading sets aria-busy and disables the control; announce the result after the action completes.
  • The focus ring uses the RUI accent and remains visible in light and dark appearances.
  • danger must be supported by a clear label and confirmation; do not rely on red alone.
  • Use xs and sm only in dense, pointer-led surfaces; larger steps keep touch targets comfortable.

In code

Import from @rumahl/ui/components and load the RUI styles once at the app root. The examples below are the same components rendered above.

Button usage
import { Button, ButtonLink } from "@rumahl/ui/components";
import "@rumahl/ui/materials.css";
import "@rumahl/ui/default-theme.css";
import "@rumahl/ui/components/controls.css";

<Button variant="primary">Save changes</Button>
<Button variant="secondary" size="sm">Cancel</Button>
<Button variant="danger">Delete</Button>
<Button variant="primary" loading>Saving…</Button>
<ButtonLink href="/settings">Open settings</ButtonLink>

Open the generated Storybook docs

On this page