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 the component from its dedicated entry point to keep the dependency and generated bundle explicit.

TSX
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

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

Primary action

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

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

Link action

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

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

Common props and defaults

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.
loadingboolean

false

Disables the action and exposes aria-busy.
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

Inherited disabled attribute accepted by Button.

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

Inherited size attribute accepted by Button.

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