Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Spinbox

An input for incrementing and decrementing numeric values.

When To Use It

Use Spinbox when users need precise step-by-step numeric control, especially where keyboard control and min/max bounds are important.

Constructing a Spinbox

Spinbox binds to a numeric value and emits changes through callbacks:

let value = Signal::new(12.0f64);

Spinbox::new(cx, value)
	.min(0.0)
	.max(100.0)
	.on_change(|cx, val| cx.emit(AppEvent::SetValue(val)));

Vertical orientation with plus/minus icons:

Spinbox::new(cx, value)
	.orientation(Orientation::Vertical)
	.icons(SpinboxIcons::PlusMinus)
	.on_increment(|cx| cx.emit(AppEvent::Increment))
	.on_decrement(|cx| cx.emit(AppEvent::Decrement));

Spinbox Modifiers

ModifierTypeDescriptionDefault
on_changeFn(&mut EventContext, f64)Called when value changes from increment/decrement/set-min/set-max.-
on_incrementFn(&mut EventContext)Called when increment action is triggered.-
on_decrementFn(&mut EventContext)Called when decrement action is triggered.-
orientationimpl Res<Orientation>Horizontal or Vertical button layout.Horizontal
iconsimpl Res<SpinboxIcons>Icon set for buttons (Chevrons, PlusMinus).Chevrons
minimpl Res<impl Into<f64>>Minimum allowed value.none
maximpl Res<impl Into<f64>>Maximum allowed value.none

Components and Styling

SelectorDescription
spinboxRoot element.
spinbox.horizontalHorizontal orientation class.
spinbox.verticalVertical orientation class.
spinbox .spinbox-buttonIncrement/decrement buttons.
spinbox .spinbox-valueInternal textbox showing value.

Accessibility

The internal value control is exposed with role SpinButton.

Keyboard interaction:

KeyAction
ArrowUp / ArrowRightIncrement
ArrowDown / ArrowLeftDecrement
HomeSet to min (if set)
EndSet to max (if set)