Button
import { Button } from 'yarcl';Variants
Section titled “Variants”variant accepts the keys of your config’s variants. These examples use the library defaults: solid, soft, outline and ghost.
<Button>Solid</Button><Button variant="soft">Soft</Button><Button variant="outline">Outline</Button><Button variant="ghost">Ghost</Button>Colors
Section titled “Colors”color accepts the keys of your config’s colors. The text color on each background is computed for contrast in light and dark mode.
<Button color="danger">Danger</Button>size accepts the keys of your config’s sizes. A button and an Input of the same size always have the same height.
Radius
Section titled “Radius”<Button radius="rounded">rounded</Button>To make every button square without touching call sites, set a component default:
components: { Button: { radius: 'square' } }With icons
Section titled “With icons”An <svg> inside a button is sized from the size’s iconSize.
Loading
Section titled “Loading”loading shows a Spinner, disables the button and sets aria-busy. The button keeps its height.
<Button loading={saving} onClick={save}>Save changes</Button>Accessibility
Section titled “Accessibility”- Renders a native
<button>withtype="button"by default, so it never submits a form by accident. Passtype="submit"when it should. - Disabled buttons use the native
disabledattribute.
Accepts every native <button> attribute except color.
| Prop | Type | Default | Description |
|---|---|---|---|
color | Colorconfig | config.defaults.color | Semantic color, from the colors config. |
loading | boolean | Shows a Spinner, disables the button and sets aria-busy. | |
radius | 'size' | Radiusconfig | config.defaults.radius | Border radius, from the radii config, or 'size' for the radius named like the control's size. |
size | Sizeconfig | config.defaults.size | Control size, from the sizes config. |
variant | Variantconfig | config.defaults.variant | Style recipe, from the variants config. |