fossui
Components

Number Field

A numeric input with stepper buttons, min and max bounds, and keyboard increment.

A number field edits a single number. It pairs a text box with plus and minus steppers, holds the value inside optional min and max bounds, and steps by a fixed amount. Typing, the arrow keys, and the steppers all resolve to the same onChanged value.

Number field
import 'package:fossui/fossui.dart';

FossNumberField(
  value: _quantity,
  onChanged: (value) => setState(() => _quantity = value),
);

The value can be null when the box is empty, so onChanged reports num?. Pass initialValue instead of value to let the field manage its own state.

Bounds and step

min and max clamp the value; the matching stepper dims at each end. step sets the increment for the steppers and the arrow keys, and largeStep sets a coarser jump for Page Up and Page Down.

FossNumberField(
  value: _volume,
  min: 0,
  max: 11,
  step: 1,
  largeStep: 5,
  onChanged: (value) => setState(() => _volume = value),
);

Format and parse

format renders the stored number as display text, and parse reads typed text back into a number. Together they support currency, units, or grouped digits.

FossNumberField(
  value: _price,
  format: (value) => '\$${value.toStringAsFixed(2)}',
  parse: (text) => num.tryParse(text.replaceAll(RegExp(r'[^0-9.]'), '')),
  onChanged: (value) => setState(() => _price = value),
);

Size

size matches the text field scale. Use sm in dense forms and md as the default.

FossNumberField(
  value: _count,
  size: FossTextFieldSize.sm,
  onChanged: (value) => setState(() => _count = value),
);

States

Set error to mark the field invalid, and enabled: false to disable it. A disabled field skips its steppers and keyboard handling.

Number field states
FossNumberField(
  value: _amount,
  error: _amount == null,
  onChanged: (value) => setState(() => _amount = value),
);

Accessibility name

When there is no visible label, pass semanticsLabel to name the field for assistive technology.

FossNumberField(
  value: _guests,
  semanticsLabel: 'Number of guests',
  onChanged: (value) => setState(() => _guests = value),
);

One-off styling

Global retheming is the first choice, but a single field can override its resolved box with a FossNumberFieldStyle. Every field is optional and falls back to the theme.

FossNumberField(
  value: _quantity,
  style: const FossNumberFieldStyle(
    borderRadius: 12,
  ),
  onChanged: (value) => setState(() => _quantity = value),
);

API

FossNumberField

PropTypeDefaultDescription
valuenum?nullControlled value; null when the box is empty.
onChangedValueChanged<num?>?nullFires with each committed value.
initialValuenum?nullStarting value when the field is uncontrolled.
minnum?nullLower bound; the value clamps to it.
maxnum?nullUpper bound; the value clamps to it.
stepnum1Increment for the steppers and arrow keys.
largeStepnum?nullCoarser jump for Page Up and Page Down.
sizeFossTextFieldSizeFossTextFieldSize.mdField height, matching the text field scale.
formatString Function(num value)?nullRenders the value as display text.
parsenum? Function(String text)?nullReads typed text back into a number.
placeholderString?nullHint shown when the box is empty.
errorboolfalseMarks the field invalid.
enabledbooltrueWhether the field accepts input.
semanticsLabelString?nullAccessibility name for the field.
styleFossNumberFieldStyle?nullPer-instance overrides on the theme.

FossNumberFieldStyle

FieldTypeDefaultDescription
backgroundColorColor?nullFill color of the field box.
borderColorColor?nullResting border color.
borderRadiusdouble?nullCorner radius in logical pixels.
minHeightdouble?nullMinimum box height; grows with text scale.
textStyleTextStyle?nullStyle of the value and placeholder; color stays token-driven.
iconSizedouble?nullPainted stepper glyph size in logical pixels.
stepperHoverColorColor?nullFill painted under a hovered stepper.
shadowList<BoxShadow>?nullDrop shadow layers at rest.

Live demo

Open the interactive gallery to try every size and state with live knobs.

On this page