shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Toggle Group

A set of two-state buttons that can be toggled on or off.

package examples import (

Installation

shadcn-templ add toggle-group

Usage

import "github.com/axadrn/shadcn-templ/v2/components/togglegroup"
@togglegroup.ToggleGroup(togglegroup.Props{}) {	@togglegroup.Item(togglegroup.ItemProps{Value: "a"}) {		A	}	@togglegroup.Item(togglegroup.ItemProps{Value: "b"}) {		B	}	@togglegroup.Item(togglegroup.ItemProps{Value: "c"}) {		C	}}

Composition

Use the following composition to build a ToggleGroup:

togglegroup.ToggleGroup├── togglegroup.Item└── togglegroup.Item

Outline

Use Variant: togglegroup.VariantOutline for an outline style.

package examples import (

Size

Use the Size prop to change the size of the toggle group.

package examples import (

Spacing

Use Spacing to add spacing between toggle group items.

package examples import (

Vertical

Use Orientation: togglegroup.OrientationVertical for vertical toggle groups.

package examples import (

Disabled

package examples import (

Custom

A custom toggle group example.

Use font-normal to set the font weight.

package examples import (

API Reference

ToggleGroup

The togglegroup.ToggleGroup component wraps its items into a single or multiple selection group.

Prop Type Default
ToggleMultiple bool false
Variant VariantDefault | VariantOutline default
Size SizeDefault | SizeSm | SizeLg default
Spacing *int 0
Orientation OrientationHorizontal | OrientationVertical horizontal
Disabled bool false
Class string -