Button
The primary action control. A row of actions where one action is committed.
Native preview
No iframeOverview
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.
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
| Variant | Role |
|---|---|
| secondary | Everyday action; the default glass control. |
| primary | Accent-tinted call to action; use one per view or region. |
| ghost | No fill; low emphasis in toolbars and inline contexts. |
| danger | Destructive action; never the default action. |
Sizes
| Size | Height | Use |
|---|---|---|
| xs | 26 px | Dense desktop toolbars. |
| sm | 30 px | Compact rows and secondary controls. |
| md | 36 px | Default size. |
| lg | 44 px | Prominent actions and touch surfaces. |
| xl | 52 px | Large surfaces and onboarding. |
States
| State | Behavior |
|---|---|
| floating | Sits over a picture or another surface; treat it as its own island. |
| glass={false} | Flat fill without the glass material. |
| active | Persistent pressed or selected state. |
| loading | Shows a spinner, sets aria-busy and disables the button. |
| success | In-place success feedback that keeps the button width. |
| disabled | 50% opacity and no pointer interaction. |
Props
| Prop | Type | Description |
|---|---|---|
| variant | 'primary' | 'secondary' | 'ghost' | 'danger' | Visual role of the action. |
| size | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | Shared control size scale. |
| color | string | Overrides the accent for this element only. |
| backgroundColor | string | Explicit fill colour, independent of color. |
| leftIcon / rightIcon | ReactNode | Optional leading or trailing icon. |
| loading | boolean | Spinner, aria-busy and disabled interaction. |
| success | boolean | In-place success state. |
| active | boolean | Persistent pressed or selected state. |
| floating | boolean | Element state for controls over a background. |
| glass | boolean | Set false for a flat fill. |
| leftFlat / rightFlat | boolean | Flat corners for joined actions. |
| noSidePadding | boolean | Removes horizontal padding for icon-only content. |
| insetFocus | boolean | Draws the focus ring inside the button. |
| native props | button / anchor props | onClick, type, aria-* and other native props are forwarded. |
Accessibility
Buttonrenders a nativebutton;ButtonLinkrenders an anchor with the same visual contract.- Keep a visible label. Icon-only actions need an
aria-labeland enough spacing. loadingsetsaria-busyand 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.
dangermust 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>