Adding persistent date format hints to the DatePicker component #9577
-
|
My team is working on an implementation of RAC's From an accessibility point of view, we normally won't use placeholder-style text as the only affordance for what should go into a field. For sighted users, this text gets over-written when there's data in the field, so we tend towards using visible labels for formatting details (like the expected shape of a date). (See The Anatomy of Accessible Forms: The Problem with Placeholders for more on this topic.) With the
If we want to add our own format hint text to the component, we have a couple of options I can think of:
Ideally, there would be some way for us to access the format hint text using something like <DatePicker {...props}>
{({ formatHintText }) => (
/* ... */
{label && (<Label>{label} ({formatHintText})</Label>)}
/* ... */I'm wondering if anyone else has bumped up against this problem and found an elegant solution? (Thanks for this awesome open source library. It has been a pleasure to use it to set up a design system!) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
We support something like this in our Spectrum implementation. See https://react-spectrum.adobe.com/v3/DateField.html#help-text It's implemented here: react-spectrum/packages/@react-spectrum/datepicker/src/utils.tsx Lines 23 to 46 in 1c85bcc Basically just uses |
Beta Was this translation helpful? Give feedback.


We support something like this in our Spectrum implementation. See https://react-spectrum.adobe.com/v3/DateField.html#help-text
It's implemented here:
react-spectrum/packages/@react-spectrum/datepicker/src/utils.tsx
Lines 23 to 46 in 1c85bcc