Skip to content

Spin Button

Edit a numeric draft directly or change it with increment controls.

Usage

Integer

Accept whole-number drafts and expose increment and decrement controls.

Team seatsAdjust the number of seats included in this workspace.4 seats

Allowed range: 0–20 · Step 1

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Release offsetFine-tune the offset in exact half-step increments.1.5 points

Allowed range: -10–10 · Step 0.5

Examples

Input recovery

Type a quantity directly; leaving an invalid edit restores the last accepted value.

Retry limitEnter a whole number. Leaving an invalid edit restores the saved quantity.10 retries

Allowed range: 0–20 · Step 1

API

Vue package: @sectile/vue/spin-button

Components
  • SpinButtonRoot
  • SpinButtonInput
  • SpinButtonIncrement
  • SpinButtonDecrement

Props

SpinButtonRootProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

defaultDraft

Editable draft used for uncontrolled initial state.

defaultValue

Initial value used when the component owns its state.

disabled

Whether interaction is unavailable.

draft

Controlled editable draft before commit.

label

Accessible name announced for the control.

max

Largest value accepted by the component.

min

Smallest value accepted by the component.

modelValue

Current value when state is controlled by the parent.

pageStep

Larger increment used by Page Up and Page Down.

policies

Behavior policies that customize validation, movement, or selection.

readonly

Whether the value can be inspected but not changed.

step

Smallest value increment accepted by the component.

SpinButtonInputProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

form

ID of the native form associated with the control.

name

Name used for native form submission.

required

Whether the control must contain a valid value before submission.

SpinButtonTriggerProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

Slots

SpinButtonSlotProps

disabled

Whether interaction is unavailable.

draft

Current uncommitted input text.

readonly

Whether the value can be inspected but not changed.

text

Formatted text for the current value.

value

Current value exposed by this contract.

Events

SpinButtonRoot

update:draft

Emitted when the editable draft changes.

update:modelValue

Emitted when the component requests a new controlled value.

Other types

SpinButtonValueChangeHandler

ts
type SpinButtonValueChangeHandler = (value: string) => void

SpinButtonDraftChangeHandler

ts
type SpinButtonDraftChangeHandler = (value: string | null) => void

Parts

Shared scope: [data-scope="spin-button"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
root[data-part="root"]Defines the component boundary and owns its composed parts.
input[data-part="input"]Accepts the editable value or draft.
increment[data-part="increment"]Increases the value by one configured step.
decrement[data-part="decrement"]Decreases the value by one configured step.

Keyboard interaction

KeyBehavior
Arrow Right / Arrow UpIncrease the value by one step.
Arrow Left / Arrow DownDecrease the value by one step.
Home / EndMove to the minimum or maximum value.
Page Up / Page DownChange the value by the configured page step when supported.

Accessibility

The input exposes spinbutton value metadata while increment and decrement remain named native controls.

See the corresponding WAI-ARIA pattern for the host accessibility contract.

Released under the MIT License.