Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-selectors] Expose date input picker affordance as a pseudo element #8359

Open
tylersticka opened this issue Jan 25, 2023 · 0 comments
Open
Labels
css-ui-4 Current Work open-ui Issues that desire to have Open UI input topic: form controls

Comments

@tylersticka
Copy link

tylersticka commented Jan 25, 2023

Some browsers include a small calendar icon as an extra visual affordance and/or focusable date picker toggle for input elements with a type of date.

Here is an example of a barebones <input type="date"> in Firefox:

Screenshot 2023-01-24 at 12 03 03 PM

In Chrome and Edge, this affordance may be selected using the -webkit-calendar-picker-indicator pseudo element. But there is currently no comparable element in Firefox, and no documented standard that I could find (though @AmeliaBR kindly pointed me toward related issues like #5365 and #3934).

The most common use case for having this pseudo element would be to customize the appearance of the icon, perhaps for consistency with the rest of a site's experience. The use case I personally encountered was simpler: We had a report of users being confused by an affordance-less date input in Safari. We wanted to provide our own calendar icon, but only for browsers that didn't provide their own.

In theory, we'd be able to use some CSS like this (see CodePen example):

@supports not selector(::-webkit-calendar-picker-indicator) {
  input[type=date] {
    background-image: url('calendar-icon.svg');
  }
}

This works great in Chromium, which shows the native affordance:

Screenshot 2023-01-25 at 11 22 55 AM

And Safari, which shows the fallback image:

Screenshot 2023-01-25 at 11 23 03 AM

But since Firefox doesn't have a comparable pseudo element to test against, it shows both the fallback and the native affordance:

Screenshot 2023-01-25 at 11 22 31 AM

It would be helpful to have a standard in place for consistency.

@fantasai fantasai added css-ui-4 Current Work open-ui Issues that desire to have Open UI input labels Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-ui-4 Current Work open-ui Issues that desire to have Open UI input topic: form controls
Projects
None yet
Development

No branches or pull requests

3 participants