Input I18n
Inputs all include robust multiple language support, with additional locale support for date, time, and number inputs. Complex locale supprt is abstracted into localizers, making it easy to use inputs with whichever date or i18n library you want.
#
MessagesMost inputs include some amount natural language: button text, ARIA-labels, etc.
Each string is customizable per component with their messages
prop. They can also be
configured for all components via a Localization
Provider, rendered near your app's
root.
You can still override messages at the component level wih the messages prop.
#
Read directionEach input repects the dir
attribute for controlling the read direction.
#
Date and number formattingLocale specific date and number formatting handled using
JavaScript's Intl
API. These
localizers are enabled by default, but can be configured directly if needed.
Note that the date localizer includes a firstOfWeek
parameter. It's not currently
possible to infer this value with the use of the Intl API, so needs to be provided
seperately. Other localizers do not require this.
Heads up
Intl
provides robust date and number formatting API's but no control over locale
based parsing. Instead, new Date
and parseFloat
are used to parse values back from
string. If you need more control over parsing, consider another localizer or provide a
custom parse
prop
#
Other LocalizersAdditional localizers are supported as seperate package installs to not bloat the core library when not used.
date
#
Moment.js See the official Moment docs for information on integrating Moment into your build pipeline effectively.
Moment format props accept string
s
date
#
date-fns See the official date-fns docs for information on integrating date-fns.
The date-fns
localizer is a convenient option to get up and running quickly as it is ready-to-use with
the en-US
locale without any configuration, and includes only the date-fns
bits that are used
for formatting and parsing dates so the additional bundle size should be minimal.
Additional locales can be included and date formats overridden by passing them as options to the localizer function.
date-fns format props accept string
s
number
#
Simple Number The simple-number
localizer provides a minimal token based number formatting and parsing strategy. Its best when you don't need
robust locale support for currencies, and numbers;
Check out the documentation for format-number-with-string for a complete guide to its format syntax.
#
Creating a LocalizerNew localizers are easy to create, either by sub-classing an existing one to customize it or by creating a new one entirely by implementing the Localizer interface for either Dates or Numbers.
Consult the source code and TypeScript types for details on what interface needs to be implemented.