Skip to content
Glint UI

SpinBox

A bounded number with steppers, clamped on the way in.

Usage

import { SpinBox } from "@glint/components/spin-box.slint";
export component AppWindow inherits Window {
in-out property <float> guest-count: 2;
VerticalLayout {
alignment: center;
SpinBox {
minimum: 1;
maximum: 10;
step: 1;
value <=> root.guest-count;
changed(new-count) => {
// handle quantity update
}
}
}
}

SpinBox allows users to increase or decrease numeric values using stepper chevron buttons, keyboard arrow keys, or direct numerical typing with automatic bounds clamping upon commit.

Examples

Custom step increments

Use step to define the amount added or subtracted per step (such as step: 5 or step: 0.5).

Strict bounds clamping

Typing an out-of-range number automatically clamps to minimum and maximum upon pressing Enter or blurring the field.

Disabled state

Setting enabled: false dims the spinbox and disables typing and stepper buttons.

API Reference

Properties

PropertyTypeDefaultDescription
valuein-out float0Two-way; kept inside minimum..maximum (see the header note about an out-of-range initial binding).
minimumin float0Lower bound (inclusive).
maximumin float100Upper bound (inclusive).
stepin float1Amount one stepper click or one arrow key adds or removes.
enabledin booltrueWhen false, the control dims and stops accepting input.
textout stringno defaultWhat the field shows. Equal to value except mid-edit, while a half-typed entry ("1", "-", or one that overshoots a bound) is on screen.

Callbacks

CallbackDescription
changed(float)Fired with the new value whenever it actually moves.

Functions

FunctionDescription
increment()Adds one step, bounded by maximum.
decrement()Removes one step, bounded by minimum.

Accessibility

  • Spinbox role. Publishes a single accessible-role: spinbox node with accessible-value, accessible-value-minimum, accessible-value-maximum, and accessible-value-step.
  • Keyboard navigation. increments, decrements, and typed numbers are clamped upon Enter.
  • Focus ring. Displays a focus ring when active.