KANTO DS v1.12.0
Customise

Theme

Accent

Font

Corners

Density

Text size

Reset to Kanto
Forms

kt-number-input

GitHub Copy link

A number field with − and + beside it: a quantity, a seat count, an amount.

Preview

A number field with − and + beside it: a quantity, a seat count, an amount.

<kt-number-input label="Seats" min="1" max="50" value="5"></kt-number-input>amount.formatOptions = { style: 'currency', currency: 'EUR' };

Typing and stepping

Type a number the way your language writes one — 1 234,5 in French, 1,234.5 in English — or step it:

KeyDoes
↑ / ↓one step up or down
Page Up/Downten steps
Home/Endto min or max
Enterreads what was typed

The − and + buttons step too, and grey out at the bounds. They stay out of the tab order: the arrows already do their work from the field.

What is typed is read when the field is left, or on Enter, and kept within min and max and on step. Text that is no number puts back the value the field had; an emptied field holds null.

Reading at rest

While the field has the focus it shows the plain number, easy to edit. At rest it reads the way the locale writes it, through formatOptions — any Intl.NumberFormat option: a currency, a percentage, a unit, a number of decimals. A screen reader hears that text as the value.

In a form

A form control: it submits the number under name, and nothing while empty. required blocks submission while it is empty, error shows a message, and form.reset() puts back the first value.

API

PropertyAttributeTypeDefault
valuevaluenumber | nullnull
minminnumbernone
maxmaxnumbernone
stepstepnumber1
formatOptions—Intl.NumberFormatOptions{}
localelocalestringpage, then browser
namenamestring''
labellabelstring''
placeholderplaceholderstring''
sizesize'small' | 'medium' | 'large''medium'
disableddisabledbooleanfalse
requiredrequiredbooleanfalse
errorerrorstring''
EventDetail
kt-change{ value: number | null }
PartDescription
fieldThe field
inputThe text field
decreaseThe − button
increaseThe + button

Accessibility

The field is a spinbutton with its bounds, its value and the text it shows; error is announced with it.