Components

Button

A pill-shaped action in four variants and three sizes, with icon-only and loading states.

Usage

import { Button } from 'nyctoui/button'

<Button variant="primary">Create issue</Button>

Good for

  • Save and Cancel at the foot of a settings form.
  • Toolbar actions in a document editor, as small ghost buttons with icons.
  • A Delete project action on a danger zone settings card.
  • A Pay or Place order action at the end of a checkout.

Examples

Variants

primary is the one main action in a view. secondary, the default, is a borderless tinted fill. ghost shows only on hover, for toolbars and rows. danger is for actions that destroy something.

Sizes

24, 32 and 40px tall, the same scale as inputs and select triggers, so controls in a row line up.

With icons

Icons are plain children at size={16}. The gap between icon and label scales with the size.

Icon only

iconOnly makes the button square. It has no visible text, so give it an aria-label.

Loading

A spinner replaces the label while the button keeps its width. The button stays focusable, so focus is not lost when a form submits.

Disabled

For navigation, use ButtonLink. It renders an <a> with the same look; pass render to use a router link. A link keeps its own role, so assistive technology knows it goes somewhere.

Best practices

Do
  • Keep primary for the one most important action in a view, and use secondary or ghost for the rest.
  • Name the action with a verb and its object: “Save changes”, “Send invite”, “Delete project”, never “OK” or “Click here”.
  • Set loading while the action runs, so people can see it’s working and don’t press twice.
  • Give an iconOnly button an aria-label, and a tooltip with the same words for people who don’t know the icon.
Don’t
  • Put two primary buttons side by side; neither reads as the main action.
  • Use danger for an irreversible action without asking first. Confirm it in an alert dialog.
  • Use a button to go to another page. Use ButtonLink, or a link, so it behaves like one.

API reference

Button

Wraps ui-sdk’s Button and accepts its props, such as render and focusableWhenDisabled. An onClick that returns a promise keeps the button pending until it settles.

PropTypeDefault
variant
Visual treatment.
'primary' | 'secondary' | 'ghost' | 'danger''secondary'
size
Control height: 24, 32 or 40px.
'sm' | 'md' | 'lg''md'
iconOnly
Square the button for a single icon. Pass an aria-label.
booleanfalse
loading
Show a spinner and block interaction while keeping the width.
booleanfalse
disabled
Dims the button and ignores presses.
booleanfalse
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

An <a> styled as a button. Takes anchor props and render.

PropTypeDefault
variant
Visual treatment.
'primary' | 'secondary' | 'ghost' | 'danger''secondary'
size
Control height: 24, 32 or 40px.
'sm' | 'md' | 'lg''md'
iconOnly
Square the link for a single icon. Pass an aria-label.
booleanfalse
render
Replaces the <a>, e.g. render={<Link to="/" />}.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—