Navigated to /docs/ui/components/toggle-group

ToggleGroup

Compact single- or multi-select choice set rendered as connected toggles.

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 { ToggleGroup } from "@tavojs/ui/toggle-group";

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/toggle-group.

When to use

Use it when

Use ToggleGroup for choices such as view mode, alignment, density, or active tools when labels are short and options fit on one line.

Choose something else when

Use Tabs when selection changes a labelled content panel, RadioGroup for conventional form choices, and Select when space is constrained or options are numerous.

Examples

ToggleGroup example

TSX
tsximport { ToggleGroup } from "@tavojs/ui/toggle-group";

export function ToggleGroupExample1() {
  return (
    <>
      <ToggleGroup
        name="view"
        value="grid"
        items={[{ label: "List", value: "list" }, { label: "Grid", value: "grid" }]}
      />
    </>
  );
}

Common props and defaults

PropTypeDefaultDescription
classNamestring

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

Configures name for this component.
valuestring | string[]

Configures value for this component.
items{ label: string; value: string; disabled?: boolean }[]

Required

Configures items for this component.
type"single" | "multiple"

Configures type for this component.
sizeSize

Configures size for this component.
variant"default" | "outline" | "ghost"

Configures variant for this component.

Complete TypeScript API

Import from @tavojs/ui/toggle-group. Published exports: ToggleGroup, ToggleGroupItem, ToggleGroupProps.

ToggleGroupProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by ToggleGroup.

classNamestring

No

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

sxSx

No

Inherited sx attribute accepted by ToggleGroup.

idstring

No

Inherited id attribute accepted by ToggleGroup.

rolestring

No

Inherited role attribute accepted by ToggleGroup.

styleRecord<string, unknown>

No

Inherited style attribute accepted by ToggleGroup.

titlestring

No

Inherited title attribute accepted by ToggleGroup.

tabIndexnumber

No

Inherited tabIndex attribute accepted by ToggleGroup.

hiddenboolean

No

Inherited hidden attribute accepted by ToggleGroup.

disabledboolean

No

Inherited disabled attribute accepted by ToggleGroup.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by ToggleGroup.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by ToggleGroup.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by ToggleGroup.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by ToggleGroup.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by ToggleGroup.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by ToggleGroup.

namestring

No

Configures name for this component.

valuestring | string[]

No

Configures value for this component.

itemsToggleGroupItem[]

Yes

Configures items for this component.

type"single" | "multiple"

No

Configures type for this component.

sizeSize

No

Configures size for this component.

variantToggleVariant

No

Configures variant for this component.

State ownership and DOM target

ConcernContract
StateApplication controlled through value and the matching callback.
DOM targetNative input attributes target the owned form control; wrapper-specific props stay on the documented component root.

Anatomy and related components

Public compound members: Root, Item

Limitations

Use Tabs when selection changes a labelled content panel, RadioGroup for conventional form choices, and Select when space is constrained or options are numerous.

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

Form components pass through native attributes and should be paired with visible labels or accessible names.

  • Use Field, FormLabel, FormControlLabel, or aria-label for labeling.

  • Preserve native input semantics whenever possible.

  • Expose validation with error text and aria-invalid where relevant.

Component status

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