w3c / w3c/csswg-drafts

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

Open
#8,359 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-ui-4 open-ui topic: form controls
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the linked Firefox Bugzilla report and related CSSWG issues #5365 and #3934, then examine how the CSSWG drafts handle comparable pseudo-elements. Done means the Working Group has resolved the proposed date-picker affordance and specified its interoperable pseudo-element behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.