Skip to content

Conversation

@adamwathan
Copy link
Member

This PR adds some additional styles to Preflight to normalize a bunch of inconsistencies in date/time inputs across browsers.

The main motivation for this is to remove these insane classes we have to add in Catalyst:

<input type="date" class="[&::-webkit-datetime-edit-fields-wrapper]:p-0 [&::-webkit-date-and-time-value]:min-h-[1.5em]
[&::-webkit-datetime-edit]:inline-flex [&::-webkit-datetime-edit]:p-0 [&::-webkit-datetime-edit-year-field]:p-0
[&::-webkit-datetime-edit-month-field]:p-0 [&::-webkit-datetime-edit-day-field]:p-0
[&::-webkit-datetime-edit-hour-field]:p-0 [&::-webkit-datetime-edit-minute-field]:p-0
[&::-webkit-datetime-edit-second-field]:p-0 [&::-webkit-datetime-edit-millisecond-field]:p-0
[&::-webkit-datetime-edit-meridiem-field]:p-0"/>

With these normalizations, changing things like padding, display type, etc. gives consistent results (at least as consistent as is actually possible) across all browsers.


Make text alignment work on iOS Safari

iOS Safari text alignment


Don't shrink date inputs on iOS Safari when there is no selected value

ioS Safari no input


Fix padding in macOS Safari

MacOS Safari

@adamwathan adamwathan requested a review from a team as a code owner November 8, 2024 21:23
@adamwathan adamwathan merged commit 5da6968 into next Nov 8, 2024
1 check passed
@adamwathan adamwathan deleted the feat/reset-datetime-inputs branch November 8, 2024 21:43
tongrow pushed a commit to tongrow/tailwind-normalize that referenced this pull request Jun 2, 2025
This PR adds some additional styles to Preflight to normalize a bunch of
inconsistencies in date/time inputs across browsers.

The main motivation for this is to remove these insane classes we have
to add in Catalyst:

```html
<input type="date" class="[&::-webkit-datetime-edit-fields-wrapper]:p-0 [&::-webkit-date-and-time-value]:min-h-[1.5em]
[&::-webkit-datetime-edit]:inline-flex [&::-webkit-datetime-edit]:p-0 [&::-webkit-datetime-edit-year-field]:p-0
[&::-webkit-datetime-edit-month-field]:p-0 [&::-webkit-datetime-edit-day-field]:p-0
[&::-webkit-datetime-edit-hour-field]:p-0 [&::-webkit-datetime-edit-minute-field]:p-0
[&::-webkit-datetime-edit-second-field]:p-0 [&::-webkit-datetime-edit-millisecond-field]:p-0
[&::-webkit-datetime-edit-meridiem-field]:p-0"/>
```

With these normalizations, changing things like padding, display type,
etc. gives consistent results (at least as consistent as is actually
possible) across all browsers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants