Playground

Button

Triggers an action. Native button with solid, line, ghost and danger variants.

  • Built on radix-ui/Slot
  • Native <button>: Enter and Space activate, Tab focuses.
  • loading sets aria-busy and blocks clicks while keeping the label.
  • asChild renders a link without losing link semantics.
  • Styles in one file: 02-buttons.css

Import

import '@monoline/css';
import {Button} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add button

It needs radix-ui; install it if your project does not have it:

npm install radix-ui

Usage

import {Button} from '@monoline/react';

<div style={{display: 'flex', gap: 'var(--s3)', flexWrap: 'wrap'}}>
  <Button variant="solid">Write today</Button>
  <Button variant="line">Open folder</Button>
  <Button variant="ghost">Show all</Button>
  <Button variant="danger">Delete entry</Button>
</div>

Examples

Variants

One solid button per view. Everything else is line or ghost.

States

Sizes and form rows

Button, Input and NativeSelect share one height at each size (`sm`, `md`, `lg`), so they line up in a row.

asChild keeps the semantics of the child, so this is a real link.

Props

ButtonProps

PropTypeDefaultDescription
variant"danger" | "line" | "solid" | "ghost"'solid'Default `solid`: the one main action per view. `line` for the rest, `ghost` for inline links, `danger` for destructive.
size"sm" | "md" | "lg"'md'`md` (default), `sm` for dense toolbars and table rows, or `lg` for prominent calls to action. Same heights as Input and Select.
loadingbooleanfalseShows a spinner, sets `aria-busy` and ignores clicks. The label stays so the width does not jump.
asChildbooleanfalseRender the child element (a link, a router link) with the button styles instead of a `<button>`.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.btn02-buttons.css
.btn-block02-buttons.css
.btn-danger02-buttons.css
.btn-ghost02-buttons.css
.btn-lg02-buttons.css
.btn-line02-buttons.css
.btn-sm02-buttons.css
.btn-solid02-buttons.css
.skeleton13-loading.css
.skeleton-block13-loading.css
.skeleton-hatch13-loading.css
.spinner13-loading.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.btn {
  border-color: var(--accent);
}

Try the props

Change a prop and the component above updates; the code below is what you would write. To edit the code itself, use the Playground.

example.tsx
<Button variant="solid">Save changes</Button>

Accessibility

  • Native <button>: Enter and Space activate, Tab focuses.
  • loading sets aria-busy and blocks clicks while keeping the label.
  • asChild renders a link without losing link semantics.

Keyboard

KeysAction
Enter / SpaceActivate
TabFocuses