Button
Action control with solid, soft, outline, and ghost variants.
Preview
A live, theme-aware example rendered with the published component.
Loading preview…
Import
Import the component from its dedicated entry point to keep the dependency and generated bundle explicit.
tsximport { Button } from "@tavojs/ui/button";Normal Tavo.js applications load component styles through the Tavo.js UI plugin. If the application manages component CSS manually, also import @tavojs/ui/css/button.
When to use
Use it when
Choose something else when
Examples
Primary action
tsximport { Button } from "@tavojs/ui/button";
export function ButtonExample1() {
return (
<>
<Button variant="solid" tone="primary">Save</Button>
</>
);
}Link action
tsximport { Button } from "@tavojs/ui/button";
export function ButtonExample2() {
return (
<>
<Button as="a" href="/settings" variant="soft">Settings</Button>
</>
);
}Common props and defaults
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
as | string | Component<Record<string, unknown>> | — | Changes the rendered root element or component while preserving Tavo.js UI styling and public props. |
variant | "solid" | "soft" | "outline" | "ghost" | "text" | solid | Visual treatment. |
tone | "primary" | "secondary" | "neutral" | "danger" | primary | Action tone. |
loading | boolean | false | Disables the action and exposes aria-busy. |
iconOnly | boolean | false | Uses square icon-only sizing; pair with label or aria-label. |
Complete TypeScript API
Import from @tavojs/ui/button. Published exports: Button, ButtonProps, ButtonTone, ButtonVariant.
ButtonProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by Button. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by Button. |
id | string | No | Inherited id attribute accepted by Button. |
role | string | No | Inherited role attribute accepted by Button. |
style | Record<string, unknown> | No | Inherited style attribute accepted by Button. |
title | string | No | Inherited title attribute accepted by Button. |
tabIndex | number | No | Inherited tabIndex attribute accepted by Button. |
hidden | boolean | No | Inherited hidden attribute accepted by Button. |
disabled | boolean | No | Inherited disabled attribute accepted by Button. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by Button. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by Button. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by Button. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by Button. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by Button. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by Button. |
as | PolymorphicAs | No | Changes the rendered root element or component while preserving Tavo.js UI styling and public props. |
variant | ButtonVariant | No | Visual treatment. |
tone | ButtonTone | No | Action tone. |
size | Size | No | Inherited size attribute accepted by Button. |
loading | boolean | No | Disables the action and exposes aria-busy. |
type | string | No | Inherited type attribute accepted by Button. |
iconOnly | boolean | No | Uses square icon-only sizing; pair with label or aria-label. |
label | string | No | Inherited label attribute accepted by Button. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | No component state contract is exposed; the application owns the rendered content and surrounding behavior. |
| DOM target | The public root follows the as/component prop. Root attributes, className, style, and supported events are forwarded there. |
Anatomy and related components
This component exposes one public component root rather than a compound member API.
Limitations
Avoid for navigation lists; use Link, Menubar, NavigationMenu, or Breadcrumbs.
Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.
Accessibility
`loading` sets `aria-busy` and disables the button or link action.
`loading` sets `aria-busy` and disables the button or link action.
Component status
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | forms |
| Component import | @tavojs/ui/button |
| Explicit CSS import | @tavojs/ui/css/button |
| Preview | Interactive preview available on this page |