# Button (@limerdev/zest) A button, or a link styled as one when it has `href`. `loading` shows a spinner while the action it started runs: the button keeps focus, is marked busy and ignores clicks. - Category: Actions - Import: `import { Button, buttonVariants } from '@limerdev/zest'` - Bits UI: `Button`, https://bits-ui.com/docs/components/button - Exports: `Button`, `buttonVariants` - Use for: Actions: submitting a form, opening a dialog, a toolbar command. With `href`, a navigation that should look like an action. - Don't: A `
` or `` with `onclick`. A Button without text: give an icon-only button `aria-label`. `variant="link"` for in-text links: use a plain ``. `disabled` while an action runs: use `loading`, which keeps focus on the button. ```svelte ``` Props of `Button`: - `disabled` (`null | false | true`, default `false`) - `href` (`string | null`, default `undefined`) - `loading` (`boolean`, default `false`): Waiting for the action it started: a spinner shows (in place of the icon of an `icon`-size button), it is marked busy and unavailable, and clicks do nothing. Unlike `disabled`, it keeps keyboard focus. - `size` (`"default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg"`, default `'default'`): The height and padding, from the theme's field size; the `icon` sizes are square. - `type` (`null | "button" | "submit" | "reset"`, default `'button'`) - `variant` (`"link" | "primary" | "secondary" | "neutral" | "error" | "outline" | "ghost"`, default `'primary'`): The look, by the theme's colour roles: `primary` for the main action, `error` for deleting, `secondary`, `neutral` and `outline` for the rest, `ghost` in toolbars, `link` for a navigation that looks like text. Example: Variants The variants, by the theme's colour roles: primary for the main action, error for deleting, secondary, neutral and outline for the rest, ghost in toolbars, link for a navigation that looks like text. ```svelte ``` Example: Sizes sm, default and lg follow the theme's field size; the icon sizes are square. Give an icon-only button an aria-label. ```svelte ``` Example: With an icon An icon before the text gets a little less padding. ```svelte ``` Example: Link and disabled With href the button is a link. A disabled link loses its href and leaves the tab order. ```svelte ``` Example: Loading loading shows a spinner while the action runs: the button keeps focus, is marked busy, and ignores clicks until it is done. ```svelte ```