Navigated to /docs/ui/components/button

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 from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.

TSX
tsximport { Button } from "@tavojs/ui/button";

The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/button.

When to use

Use it when

Use Button for primary, secondary, destructive, or link-style actions.

Choose something else when

Avoid for navigation lists; use Link, Menubar, NavigationMenu, or Breadcrumbs.

Examples

These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.

Primary action

TSXCreate: src/components/examples/ButtonExample1.tsx
tsximport { Button } from "@tavojs/ui/button";

export function ButtonExample1() {
  return (
    <>
      <Button variant="solid" tone="primary">Save</Button>
    </>
  );
}

Link action

TSXCreate: src/components/examples/ButtonExample2.tsx
tsximport { Button } from "@tavojs/ui/button";

export function ButtonExample2() {
  return (
    <>
      <Button as="a" href="/settings" variant="soft">Settings</Button>
    </>
  );
}

Common props and defaults

A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
asstring | 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.
sizeSize

Configures size for this component.
loadingboolean

false

Disables the action and exposes aria-busy.
disabledboolean

Configures disabled for this component.
iconOnlyboolean

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

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by Button.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by Button.

idstring

No

Inherited id attribute accepted by Button.

rolestring

No

Inherited role attribute accepted by Button.

styleRecord<string, unknown>

No

Inherited style attribute accepted by Button.

titlestring

No

Inherited title attribute accepted by Button.

tabIndexnumber

No

Inherited tabIndex attribute accepted by Button.

hiddenboolean

No

Inherited hidden attribute accepted by Button.

disabledboolean

No

Configures disabled for this component.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by Button.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by Button.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by Button.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by Button.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by Button.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by Button.

asPolymorphicAs

No

Changes the rendered root element or component while preserving Tavo.js UI styling and public props.

variantButtonVariant

No

Visual treatment.

toneButtonTone

No

Action tone.

sizeSize

No

Configures size for this component.

loadingboolean

No

Disables the action and exposes aria-busy.

typestring

No

Inherited type attribute accepted by Button.

iconOnlyboolean

No

Uses square icon-only sizing; pair with label or aria-label.

labelstring

No

Inherited label attribute accepted by Button.

State ownership and DOM target

ConcernContract
StateNo component state contract is exposed; the application owns the rendered content and surrounding behavior.
DOM targetThe 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

ContractCurrent value
Maturitystable
Categoryforms
Component import@tavojs/ui/button
Explicit CSS import@tavojs/ui/css/button
PreviewInteractive preview available on this page