Skip to content

Commit

Permalink
Fix text alignment on date and time inputs on iOS (#144)
Browse files Browse the repository at this point in the history
* Fix text alignment on date and time inputs on iOS

* Update index.js

---------

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
  • Loading branch information
reinink and adamwathan committed Aug 22, 2023
1 parent e60d81a commit 5a13e94
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/index.js
Expand Up @@ -95,6 +95,17 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
'min-height': '1.5em',
},
},
{
// In Safari on iOS date and time inputs are centered instead of left-aligned and can't be
// changed with `text-align` utilities on the input by default. Resetting this to `inherit`
// makes them left-aligned by default and makes it possible to override the alignment with
// utility classes without using an arbitrary variant to target the pseudo-elements.
base: ['::-webkit-date-and-time-value'],
class: ['.form-input::-webkit-date-and-time-value'],
styles: {
'text-align': 'inherit',
},
},
{
// In Safari on macOS date time inputs are 4px taller than normal inputs
// This is because there is extra padding on the datetime-edit and datetime-edit-{part}-field pseudo elements
Expand Down

1 comment on commit 5a13e94

@vercel
Copy link

@vercel vercel bot commented on 5a13e94 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.