Button
A native <button> element for actions like submit, save, continue, or delete. It is a plain HTML part, so it works everywhere a button can work, with no extra setup.
Import
tsx
import { Button } from "@aizvi/ui";Basic example
tsx
<Button variant="primary">Continue</Button>Live preview
Variants
Button ships with five looks. Pick the one that matches how important the action is.
tsx
<Button variant="primary">Primary</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="outline">Outline</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="danger">Danger</Button>Live preview
Use danger for actions that remove or destroy something, like deleting an account.
Sizes
tsx
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>Live preview
Loading state
Set loading to show a small spinner and mark the button busy, without changing its width or height.
tsx
<Button loading>Saving</Button>Live preview
While loading is true, the button is also disabled, so a user cannot click it twice by accident.
Full width
tsx
<Button fullWidth>Continue</Button>Icons
startIcon and endIcon place any content, such as an icon, before or after the label. They are hidden automatically while the button is loading.
tsx
<Button startIcon={<PlusIcon />}>Add item</Button>Props
Button accepts every normal <button> attribute, plus these.
variant, one ofprimary,secondary,outline,ghost, ordanger. The default isprimary.size, one ofsm,md, orlg. The default ismd.loading, a boolean. Shows a spinner and marks the button busy. The default isfalse.fullWidth, a boolean. Stretches the button to fill its parent. The default isfalse.startIcon, any content shown before the label.endIcon, any content shown after the label.
Accessibility
- Button always renders a real
<button>, so it is reachable with the Tab key, and it can be activated with Enter or Space, just like any native button. typedefaults to"button", so a Button placed inside a form never submits that form by accident. Settype="submit"yourself when you want that behavior.- While
loadingis true, the button getsaria-busy="true", so a screen reader can tell the user that something is in progress. - The focus ring is always visible when the button is reached with a keyboard.