---
title: Toggle group
description: A segmented control — one pill of mutually exclusive choices, where the selected segment carries a raised plate.
source: https://github.com/crabtalk/bezel/blob/main/crates/ui/src/widgets/controls.rs
---

> One page of the bezel documentation. The index is https://bezel.gallery/llms.txt

# Toggle group

```rust
use ui::widgets::Controls;

theme.toggle_group().children(
    ["Day", "Week", "Month"].into_iter().enumerate().map(|(index, label)| {
        theme.toggle_group_item(label, self.segment == index)
    }),
)
```

Reach for this over a [select](/docs/select) when there are few enough choices that a menu would be overkill.

## API

```rust
pub trait Controls: ThemeExt {
    /// The track. Sets `self_start`, or flexbox's default `stretch` blows it
    /// out to a column's full width.
    fn toggle_group(&self) -> Div;

    /// Exactly one reads as pressed; the rest stay bare.
    fn toggle_group_item(&self, label: impl Into<SharedString>, selected: bool) -> Div;

    // ...
}
```

Segment corners derive from the track's radius and its inset — both numbers are read at both ends, so a segment cannot stop being concentric with its track.
