Skip to content

Commit 5a13e94

Browse files
reininkadamwathan
andauthored
Fix text alignment on date and time inputs on iOS (#144)
* Fix text alignment on date and time inputs on iOS * Update index.js --------- Co-authored-by: Adam Wathan <[email protected]>
1 parent e60d81a commit 5a13e94

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
9595
'min-height': '1.5em',
9696
},
9797
},
98+
{
99+
// In Safari on iOS date and time inputs are centered instead of left-aligned and can't be
100+
// changed with `text-align` utilities on the input by default. Resetting this to `inherit`
101+
// makes them left-aligned by default and makes it possible to override the alignment with
102+
// utility classes without using an arbitrary variant to target the pseudo-elements.
103+
base: ['::-webkit-date-and-time-value'],
104+
class: ['.form-input::-webkit-date-and-time-value'],
105+
styles: {
106+
'text-align': 'inherit',
107+
},
108+
},
98109
{
99110
// In Safari on macOS date time inputs are 4px taller than normal inputs
100111
// This is because there is extra padding on the datetime-edit and datetime-edit-{part}-field pseudo elements

0 commit comments

Comments
 (0)