Controls
Buttons, toggles, and a slider. Faces paint from M3 roles and
ControlState (enabled, disabled, hovered, pressed, selected) via
style and Tokens::scheme().
rustdoc ·
source ·
icedtea ·
iced
Each constructor takes A11y unless noted. iced 0.14 publishes the widget id only.
Button
button — Press a labeled control to send a message.
Constructor: widget::button
title is the face. msg is None when there is nothing to send.
A11y::button(name).with_disabled(true) drops the press handler.
Variant picks the token wash (Primary filled, Quiet tonal,
Outlined, Elevated, Ghost text). Icons is leading and trailing
chrome. ButtonOpts is width and height (SHRINK for a chrome
label, { width: Length::Fill, height } for a pad tile).
Split button
split-button — A primary press plus a more menu.
Constructor: widget::split_button
primary is the main message. more opens the overflow. Disabled
drops both.
Pass A11y.
Toggle button
toggle-button — A button that stays pressed while on.
Constructor: widget::toggle_button
Pass the current on/off state. The message fires on press. Disabled keeps the face and drops the handler. Space and Enter toggle when the button is focused.
Pass A11y.
Checkbox
checkbox — Check, clear, or mark a partial selection.
Constructor: widget::checkbox
The application owns CheckState.
Press follows CheckState::toggle. Disabled keeps the box visible
and ignores clicks. Space and Enter toggle when the box is focused.
Pass A11y.
Radio
radio — Pick one value from a small set.
Constructor: widget::radio
Compare the selected value to this option. Disabled rows stay in the group and do not change the selection. Arrows move the selection when a radio in the group is focused.
Pass A11y.
Switch
switch — A sliding on/off control.
Constructor: widget::switch
Same contract as checkbox: the application owns the bool. Disabled
freezes the thumb.
SwitchOpts::FORM is a settings row (track then caption, Fill).
SwitchOpts::BAR is a toolbar control (caption then track, shrink)
at ControlSize height, next to a compact pick.
Space and Enter toggle when the switch is focused.
Pass A11y.
Slider
slider — Pick a number on a range.
Constructor: widget::slider
Pass min, max, and the current value. SliderMarks paints ticks and
end labels, a vertical rail, and an optional thumb value label. The
message is the new value while the thumb moves. Disabled ignores drag.
Arrows nudge the value when the slider is focused.
Pass A11y.
Segmented button
segmented-button — Exclusive choice among labeled segments.
Constructor: widget::segmented_button
The application owns the selected index. Cells may carry an icon. Press emits the new index. Disabled freezes every segment. ControlSize::Compact is the in-pane exclusive strip. tab_bar stays the pane chrome.
Arrows move the segment. Enter and Space activate it.
Pass A11y.
Button group
button-group — Related actions in one strip.
Constructor: widget::button_group
Each cell is a label plus optional icon (Cell). Press sends the index.
Empty cells paint an empty row. Disabled drops every press. The
outline hugs the cells. Arrows move along the strip. Enter and Space
press the cell.
Pass A11y.
Icon button
icon-button — Icon-only press control for dense toolbars.
Constructor: widget::icon_button
Variant picks the wash. ControlSize is the hit box. Pass a shipped
Icon or Glyph::Bytes. Disabled drops the press.
Pass A11y.
Toggle icon button
toggle-icon-button — Icon button that stays pressed while on.
Constructor: widget::icon_button_toggle
Same wash as toggle button. Disabled keeps the face.
Pass A11y.
Range slider
range-slider — Inclusive low and high values on one range.
Constructor: widget::range_slider
Messages are the clamped pair with low <= high. Disabled freezes both thumbs.
Each thumb is a slider: arrows nudge the focused end.
Pass A11y.