Skip to content

Number Field

A spinbutton for numbers of any type: culture-aware formatting and parsing, steppers that repeat while held, keyboard, wheel and scrub.

Styled with CSS Tailwind

Quantity with steppers

The input is a role="spinbutton" with aria-valuenow, aria-valuemin and aria-valuemax. ↑ / ↓ step, Shift steps by LargeStep, Home / End jump to the bounds. The buttons stay out of the tab order, keep the focus in the input, repeat while held (data-pressed) and disable themselves at the bounds. @bind-Value works with any numeric type - here an int.

Value: 1

Currency, percent and culture

Format is a .NET numeric format string and Culture the culture numbers are written and read in. Type 1.234,5 in the German field or 1,234.5 in the American one: both parse, both show the culture's currency. A percent format steps by hundredths. Text that isn't a number reverts when the field is left.

Scrub area and wheel

Drag the W handle left or right: every two pixels is a step (ScrubPixelSensitivity), Shift makes it a large step, and the value is committed (OnValueCommit) when the pointer is released. With AllowWheelScrub the mouse wheel steps the focused input without scrolling the page.

Committed: 320

In a form

Inside a BitBhField the label, description and validation message are wired to the input; inside an EditForm the field validates. A nullable value can be emptied; a Name posts the culture-invariant value in a hidden input.

An unhandled error has occurred. Reload 🗙