Number input
Examples
Base
<div class="chi-form__item">
<chi-label for="example__base">Label</chi-label>
<chi-number-input id="example__base"></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__base">Label</label>
<div class="chi-number-input">
<input id="example__base" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__base'));</script>
Disabled
Use the disabled
boolean attribute to prevent users from interacting with an input.
Disabled inputs are not submitted with the form and can not receive any browsing events such as mouse clicks or focus.
Note: The required attribute can not be used on inputs with a disabled attribute specified.
<div class="chi-form__item">
<chi-label for="example__disabled">Label</chi-label>
<chi-number-input disabled id="example__disabled"></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__disabled">Label</label>
<div class="chi-number-input">
<input id="example__disabled" type="number" class="chi-input" value="0" aria-label="Input Label" disabled>
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__disabled'));</script>
Min/Max/Step
Use the min
and max
attributes to define minimum and maximum values on number inputs.
Use the step
attribute to indicate the expected granularity.
This example only accepts values between 1
and 6
, and as the step
is
2
and initial value
is 1
, only odd values are valid.
Use the chiNumberInvalid
event described in the events section
to check if the entered value is valid.
<div class="chi-form__item">
<chi-label for="example__mms">Label</chi-label>
<chi-number-input id="example__mms" min="1" max="6" step="2" value="1"></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__mms">Label</label>
<div class="chi-number-input">
<input id="example__mms" type="number" class="chi-input" min="0" max="6" step="2" value="1" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>
chi.numberInput(
document.getElementById('example__mms'),
{autofix: true}
);
</script>
Required
Use the required
boolean attribute to indicate which inputs must be completed before submitting a form.
To render a required input, apply the required
attribute to the input. It is also
encouraged but not mandatory to apply a required
attribute to the corresponding label of the input which
will automatically render a red asterisk. Note: For HTML Blueprint implementations,
the required
attribute is not supported on the label. Please use the alternate method
specified below for rendering a red asterisk within the label.
<div class="chi-form__item">
<chi-label for="example__required" required>Label</chi-label>
<chi-number-input id="example__required" required></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__required">
Label
<abbr class="chi-label__required" aria-label="Required field">*</abbr>
</label>
<div class="chi-number-input">
<input id="example__required" type="number" class="chi-input" value="0" aria-label="Input Label" required>
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__required'));</script>
Help
Use chi-label
's attributes infoIcon
and infoIconMessage
to include a help icon that displays helpful information in a popover.
<div class="chi-form__item">
<chi-label for="example__help" info-icon info-icon-message="Helpful information goes here.">Label</chi-label>
<chi-number-input id="example__help"></chi-number-input>
</div>
<div class="chi-form__item">
<div class="chi-label__wrapper">
<label class="chi-label" for="example__help">Label</label>
<div class="chi-label__help">
<div class="chi-button -icon -flat -xs" id="example__help-button" data-target="#example__help-popover" aria-label="Help">
<div class="chi-button__content">
<i class="chi-icon icon-circle-info-outline" aria-hidden="true"></i>
</div>
</div>
<section class="chi-popover chi-popover--top" id="example__help-popover" aria-modal="true" role="dialog">
<div class="chi-popover__content">
<p class="chi-popover__text">Helpful information goes here.</p>
</div>
</section>
</div>
</div>
<div class="chi-number-input">
<input id="example__help" type="number" class="chi-input" value="0" aria-label="Input Label" required>
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.popover(document.getElementById('example__help-button'));</script>
Message
Add a message below an input to store descriptions, validation feedback, and other helpful information.
<div class="chi-form__item">
<chi-label for="example__message">Label</chi-label>
<chi-number-input id="example__message" helper-message="Optional helper message"></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__message">Label</label>
<div class="chi-number-input">
<input id="example__message" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
<div class="chi-label -status">Optional helper message</div>
</div>
<script>chi.numberInput(document.getElementById('example__message'));</script>
Error
Use danger
to provide feedback to users when input data fails to validate.
To meet accessibility requirements, danger inputs must include an error message explaining the
failure and/or how to correct it.
<div class="chi-form__item">
<chi-label for="example__error">Quantity</chi-label>
<chi-number-input id="example__error" inputstyle="danger" helper-message="Please enter a quantity"></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__error">Quantity</label>
<div class="chi-number-input">
<input id="example__error" type="number" class="chi-input -danger" value="0" aria-label="Quantity">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
<div class="chi-label -status -danger">
<i class="chi-icon icon-circle-warning" aria-hidden="true"></i>
Please enter a quantity
</div>
</div>
<script>chi.numberInput(document.getElementById('example__error'));</script>
Sizes
Number inputs support the following sizes: xs
, sm
, md
,
lg
, xl
. The default size is md
.
<!-- xs -->
<div class="chi-form__item">
<chi-label for="example__size-xs">Label</chi-label>
<chi-number-input size="xs" id="example__size-xs"></chi-number-input>
</div>
<!-- sm -->
<div class="chi-form__item">
<chi-label for="example__size-sm">Label</chi-label>
<chi-number-input size="sm" id="example__size-sm"></chi-number-input>
</div>
<!-- md -->
<div class="chi-form__item">
<chi-label for="example__size-md">Label</chi-label>
<chi-number-input size="md" id="example__size-md"></chi-number-input>
</div>
<!-- lg -->
<div class="chi-form__item">
<chi-label for="example__size-lg">Label</chi-label>
<chi-number-input size="lg" id="example__size-lg"></chi-number-input>
</div>
<!-- xl -->
<div class="chi-form__item">
<chi-label for="example__size-xl">Label</chi-label>
<chi-number-input size="xl" id="example__size-xl"></chi-number-input>
</div>
<!-- xs -->
<div class="chi-form__item">
<label class="chi-label" for="example__size-xs">Label</label>
<div class="chi-number-input -xs">
<input id="example__size-xs" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__size-xs'));</script>
<!-- sm -->
<div class="chi-form__item">
<label class="chi-label" for="example__size-sm">Label</label>
<div class="chi-number-input -sm">
<input id="example__size-sm" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__size-sm'));</script>
<!-- md -->
<div class="chi-form__item">
<label class="chi-label" for="example__size-md">Label</label>
<div class="chi-number-input -md">
<input id="example__size-md" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__size-md'));</script>
<!-- lg -->
<div class="chi-form__item">
<label class="chi-label" for="example__size-lg">Label</label>
<div class="chi-number-input -lg">
<input id="example__size-lg" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__size-lg'));</script>
<!-- xl -->
<div class="chi-form__item">
<label class="chi-label" for="example__size-xl">Label</label>
<div class="chi-number-input -xl">
<input id="example__size-xl" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__size-xl'));</script>
Sizes
Number inputs support the following sizes: xs
, sm
, md
,
lg
. The default size is md
.
<!-- xs -->
<div class="chi-form__item">
<chi-label for="example__size-xs">Label</chi-label>
<chi-number-input size="xs" id="example__size-xs"></chi-number-input>
</div>
<!-- sm -->
<div class="chi-form__item">
<chi-label for="example__size-sm">Label</chi-label>
<chi-number-input size="sm" id="example__size-sm"></chi-number-input>
</div>
<!-- md -->
<div class="chi-form__item">
<chi-label for="example__size-md">Label</chi-label>
<chi-number-input size="md" id="example__size-md"></chi-number-input>
</div>
<!-- lg -->
<div class="chi-form__item">
<chi-label for="example__size-lg">Label</chi-label>
<chi-number-input size="lg" id="example__size-lg"></chi-number-input>
</div>
<!-- xs -->
<div class="chi-form__item">
<label class="chi-label" for="example__size-xs">Label</label>
<div class="chi-number-input -xs">
<input id="example__size-xs" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__size-xs'));</script>
<!-- sm -->
<div class="chi-form__item">
<label class="chi-label" for="example__size-sm">Label</label>
<div class="chi-number-input -sm">
<input id="example__size-sm" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__size-sm'));</script>
<!-- md -->
<div class="chi-form__item">
<label class="chi-label" for="example__size-md">Label</label>
<div class="chi-number-input -md">
<input id="example__size-md" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__size-md'));</script>
<!-- lg -->
<div class="chi-form__item">
<label class="chi-label" for="example__size-lg">Label</label>
<div class="chi-number-input -lg">
<input id="example__size-lg" type="number" class="chi-input" value="0" aria-label="Input Label">
<button aria-label="Decrease"></button>
<button aria-label="Increase"></button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__size-lg'));</script>
Expanded version
Base
<div class="chi-form__item">
<chi-label for="example__expanded-base">Label</chi-label>
<chi-number-input expanded id="example__expanded-base"></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-base">Label</label>
<div class="chi-number-input -expanded">
<input id="example__expanded-base" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content">
<i class="chi-icon icon-minus" aria-hidden="true"></i>
</div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content">
<i class="chi-icon icon-plus" aria-hidden="true"></i>
</div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-base'));</script>
Disabled
Use the disabled
boolean attribute to prevent users from interacting with an input.
Disabled inputs are not submitted with the form and can not receive any browsing events such as mouse clicks or focus.
Note: The required attribute can not be used on inputs with a disabled attribute specified.
<div class="chi-form__item">
<chi-label for="example__expanded-disabled">Label</chi-label>
<chi-number-input expanded disabled id="example__expanded-disabled"></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-disabled">Label</label>
<div class="chi-number-input -expanded">
<input id="example__expanded-disabled" class="chi-input" type="number" value="0" aria-label="Input Label" disabled>
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content">
<i class="chi-icon icon-minus" aria-hidden="true"></i>
</div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content">
<i class="chi-icon icon-plus" aria-hidden="true"></i>
</div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-disabled'));</script>
Min/Max/Step
Use the min
and max
attributes to define minimum and maximum values on number inputs.
Use the step
attribute to indicate the expected granularity.
This example only accepts values between 0
and 6
, and as the step
is
2
and initial value
is 1
, only odd values are valid.
Use the chiNumberInvalid
event described in the events section
to check if the entered value is valid.
<div class="chi-form__item">
<chi-label for="example__expanded-mms">Label</chi-label>
<chi-number-input expanded id="example__expanded-mms" min="1" max="6" step="2" value="1"></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-mms">Label</label>
<div class="chi-number-input -expanded">
<input id="example__expanded-mms" class="chi-input" type="number" min="0" max="6" "step="2" value="1" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content">
<i class="chi-icon icon-minus" aria-hidden="true"></i>
</div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content">
<i class="chi-icon icon-plus" aria-hidden="true"></i>
</div>
</button>
</div>
</div>
<script>
chi.numberInput(
document.getElementById('example__expanded-mms'),
{autofix: true}
);
</script>
Error
Use danger
to provide feedback to users when input data fails to validate.
To meet accessibility requirements, danger inputs must include an error message explaining the
failure and/or how to correct it.
<div class="chi-form__item">
<chi-label for="example__expanded-error">Quantity</chi-label>
<chi-number-input expanded id="example__expanded-error" inputstyle="danger" helper-message="Please enter a quantity"></chi-number-input>
</div>
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-error">Label</label>
<div class="chi-number-input -expanded">
<input id="example__expanded-error" class="chi-input -danger" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content">
<i class="chi-icon icon-minus" aria-hidden="true"></i>
</div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content">
<i class="chi-icon icon-plus" aria-hidden="true"></i>
</div>
</button>
</div>
<div class="chi-label -status -danger">
<i class="chi-icon icon-circle-warning" aria-hidden="true"></i>
Please enter a quantity
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-error'));</script>
Sizes
Expanded number inputs support the following sizes: xs
, sm
, md
,
lg
, xl
. The default size is md
.
<!-- xs -->
<div class="chi-form__item">
<chi-label for="example__expanded-size-xs">Label</chi-label>
<chi-number-input expanded size="xs" id="example__expanded-size-xs"></chi-number-input>
</div>
<!-- sm -->
<div class="chi-form__item">
<chi-label for="example__expanded-size-sm">Label</chi-label>
<chi-number-input expanded size="sm" id="example__expanded-size-sm"></chi-number-input>
</div>
<!-- md -->
<div class="chi-form__item">
<chi-label for="example__expanded-size-md">Label</chi-label>
<chi-number-input expanded size="md" id="example__expanded-size-md"></chi-number-input>
</div>
<!-- lg -->
<div class="chi-form__item">
<chi-label for="example__expanded-size-lg">Label</chi-label>
<chi-number-input expanded size="lg" id="example__expanded-size-lg"></chi-number-input>
</div>
<!-- xl -->
<div class="chi-form__item">
<chi-label for="example__expanded-size-xl">Label</chi-label>
<chi-number-input expanded size="xl" id="example__expanded-size-xl"></chi-number-input>
</div>
<!-- xs -->
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-size-xs">Label</label>
<div class="chi-number-input -expanded -xs">
<input id="example__expanded-size-xs" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content"><i class="chi-icon icon-minus" aria-hidden="true"></i></div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content"><i class="chi-icon icon-plus" aria-hidden="true"></i>
</div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-size-xs'));</script>
<!-- sm -->
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-size-sm">Label</label>
<div class="chi-number-input -expanded -sm">
<input id="example__expanded-size-sm" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content"><i class="chi-icon icon-minus" aria-hidden="true"></i></div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content"><i class="chi-icon icon-plus" aria-hidden="true"></i>
</div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-size-sm'));</script>
<!-- md -->
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-size-md">Label</label>
<div class="chi-number-input -expanded -md">
<input id="example__expanded-size-md" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content"><i class="chi-icon icon-minus" aria-hidden="true"></i></div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content"><i class="chi-icon icon-plus" aria-hidden="true"></i></div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-size-md'));</script>
<!-- lg -->
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-size-lg">Label</label>
<div class="chi-number-input -expanded -lg">
<input id="example__expanded-size-lg" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content"><i class="chi-icon icon-minus" aria-hidden="true"></i></div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content"><i class="chi-icon icon-plus" aria-hidden="true"></i></div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-size-lg'));</script>
<!-- xl -->
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-size-xl">Label</label>
<div class="chi-number-input -expanded -xl">
<input id="example__expanded-size-xl" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content"><i class="chi-icon icon-minus" aria-hidden="true"></i></div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content"><i class="chi-icon icon-plus" aria-hidden="true"></i></div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-size-xl'));</script>
Sizes
Expanded number inputs support the following sizes: xs
, sm
, md
,
lg
. The default size is md
.
<!-- xs -->
<div class="chi-form__item">
<chi-label for="example__expanded-size-xs">Label</chi-label>
<chi-number-input expanded size="xs" id="example__expanded-size-xs"></chi-number-input>
</div>
<!-- sm -->
<div class="chi-form__item">
<chi-label for="example__expanded-size-sm">Label</chi-label>
<chi-number-input expanded size="sm" id="example__expanded-size-sm"></chi-number-input>
</div>
<!-- md -->
<div class="chi-form__item">
<chi-label for="example__expanded-size-md">Label</chi-label>
<chi-number-input expanded size="md" id="example__expanded-size-md"></chi-number-input>
</div>
<!-- lg -->
<div class="chi-form__item">
<chi-label for="example__expanded-size-lg">Label</chi-label>
<chi-number-input expanded size="lg" id="example__expanded-size-lg"></chi-number-input>
</div>
<!-- xs -->
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-size-xs">Label</label>
<div class="chi-number-input -expanded -xs">
<input id="example__expanded-size-xs" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content"><i class="chi-icon icon-minus" aria-hidden="true"></i></div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content"><i class="chi-icon icon-plus" aria-hidden="true"></i>
</div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-size-xs'));</script>
<!-- sm -->
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-size-sm">Label</label>
<div class="chi-number-input -expanded -sm">
<input id="example__expanded-size-sm" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content"><i class="chi-icon icon-minus" aria-hidden="true"></i></div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content"><i class="chi-icon icon-plus" aria-hidden="true"></i>
</div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-size-sm'));</script>
<!-- md -->
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-size-md">Label</label>
<div class="chi-number-input -expanded -md">
<input id="example__expanded-size-md" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content"><i class="chi-icon icon-minus" aria-hidden="true"></i></div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content"><i class="chi-icon icon-plus" aria-hidden="true"></i></div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-size-md'));</script>
<!-- lg -->
<div class="chi-form__item">
<label class="chi-label" for="example__expanded-size-lg">Label</label>
<div class="chi-number-input -expanded -lg">
<input id="example__expanded-size-lg" class="chi-input" type="number" value="0" aria-label="Input Label">
<button class="chi-button -icon" aria-label="Decrease">
<div class="chi-button__content"><i class="chi-icon icon-minus" aria-hidden="true"></i></div>
</button>
<button class="chi-button -icon" aria-label="Increase">
<div class="chi-button__content"><i class="chi-icon icon-plus" aria-hidden="true"></i></div>
</button>
</div>
</div>
<script>chi.numberInput(document.getElementById('example__expanded-size-lg'));</script>
Web Component
Properties
Events
JavaScript
This component accepts options to configure its behavior.
Preventing memory leaks
Input number components have a dispose function to free all resources attached to the element, such as event listeners and object data. You should call this method when you want to remove the component.
var elem = document.getElementById('input-number-1');
var inputNumberComponent = chi.numberInput(elem);
// do stuff
inputNumberComponent.dispose();
TipIt is safe to call the numberInput
method more than once, as it will return any previously created
number input component associated to the input.
var elem = document.getElementById('input-number-1');
var inputNumberComponent = chi.numberInput(elem);
var elem2 = document.getElementById('input-number-1');
var inputNumberComponent2 = chi.numberInput(elem2);
inputNumberComponent === inputNumberComponent2; // returns true
inputNumberComponent.dispose(); // Only have to do it once.
Accessibility
Keyboard Navigation
Key | Function |
---|---|
Tab | Moves focus to the next focusable element. |
Shift + Tab | Moves focus to the previous focusable element. |
Up Arrow orShift +Up Arrow | Increases the value. |
Down Arrow orShift +Down Arrow | Decreases the value. |
Enter | Submits the entered value. |
For comprehensive details on keyboard support, refer to our Keyboard Control Guide.
Visit WebAIM for keyboard techniques.
Find live examples of accessible inputs with different types in DigitalA11y project.
Resources
- Mozilla Resources for Developers: Information about the HTML
input-type="number"
- A11y style guide: Describes core principles for the accessible inputs and textarea.
- MagentaA11y: How to test a number input.
Other recommendations
Explore additional accessibility tips in the general Accessibility Guide.
WCAG 2.2 Guidelines
- Non-text Content: All non-text content that is presented to the user has a text alternative that serves the equivalent purpose. (Level A)
- Info and Relationships: Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text. (Level A)
- Headings and Labels: Headings and labels describe topic or purpose. (Level AA)
- Labels or Instructions: Labels or instructions are provided when content requires user input. (Level A)
- Name, Role, Value: For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies. (Level A)