UI Toolbox logoUI Toolbox
Support

NumericUpDown

A NumericUpDown is a number field with up and down buttons. Its value is a double.

Level, gold and price boxes with up and down arrowsLevel, gold and price boxes with up and down arrows

<UIToolbox.NumericUpDown
    label="Qty"
    value="10"
    min-value="0"
    max-value="100"
    step="5" />
<UIToolbox.NumericUpDown label="Price" step="0.01" format-string="F2" />
<UIToolbox.NumericUpDown
    label="Cost"
    format-string="$#,0.00;($#,0.00)" />
<UIToolbox.NumericUpDown
    label="Tax"
    min-value="0"
    max-value="1"
    step="0.005"
    format-string="P1" />
Member Description
MinValue (min-value), MaxValue (max-value) The range. The value is clamped. A minimum above the maximum moves the maximum, and the other way around.
Step (step) How much a button, a key or a wheel notch changes the value (1).
FormatString (format-string) A .NET numeric format for the text, such as F2, N0, P1 or $#,0.00. The text uses the invariant culture.
TryParseText(text, out number) Reads a number in the look of FormatString, as the field does with typed text. Returns false for other text, such as an expression.
Increment(), Decrement() Change the value by Step.

In the examples

Styling

The rules are in Assets/UIToolbox/Runtime/Resources/UIToolbox/Styles/Controls.uss.

Class Element
tb-numeric-up-down The field.
tb-numeric-up-down__field The inner DoubleField.
tb-numeric-up-down__spinner The button column.
tb-editing On the control while the gamepad edit mode is on: the buttons have the accent fill, and the focus ring stays.
tb-numeric-up-down__up, tb-numeric-up-down__down The buttons (RepeatButton). A button at the end of the range is disabled: no fill, and the arrow in --tb-color-text-disabled.

A disabled NumericUpDown takes no focus and no typing, and its label, text and buttons have --tb-color-text-disabled. To stop a value from going up, as a stat with no points left, disable the field or the whole control, not only the up button. See Disabled state.

The NumericUpDownDemo scene shows the reward of a bounty with the defaults, a stack split, a crafting amount that the materials in the bag limit, and a settings menu with a format for each option.