Skip to content

Commit 192109b

Browse files
authored
Don't give input elements a transparent background by default (#14913)
Early in v4 development we decided to give all form controls a transparent background, but in v3 we only did this for button elements. This PR reverts that decision to make things consistent with v3, as we've noticed this is something that tends to break for people when upgrading from v3 to v4. The default background color of form elements is the [`Field` system color](https://developer.mozilla.org/en-US/docs/Web/CSS/system-color#field) which automatically adapts to light and dark modes if you don't touch it, so it feels reasonable to keep this as the default. Changing it just makes upgrading harder and doesn't really make anything easier for anyone else. --------- Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
1 parent 7b75b1a commit 192109b

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Ensure the CSS `theme()` function handles newlines and tabs in its arguments list ([#14917](https://github.com/tailwindlabs/tailwindcss/pull/14917))
3535
- Don't unset keys like `--inset-shadow-*` when unsetting keys like `--inset-*` ([#14906](https://github.com/tailwindlabs/tailwindcss/pull/14906))
3636
- Ensure spacing utilities with no value (e.g. `px` or `translate-y`) don't generate CSS ([#14911](https://github.com/tailwindlabs/tailwindcss/pull/14911))
37+
- Don't override user-agent background color for input elements in Preflight ([#14913](https://github.com/tailwindlabs/tailwindcss/pull/14913))
3738
- Don't attempt to convert CSS variables (which should already be percentages) to percentages when used as opacity modifiers ([#14916](https://github.com/tailwindlabs/tailwindcss/pull/14916))
3839
- _Upgrade (experimental)_: Install `@tailwindcss/postcss` next to `tailwindcss` ([#14830](https://github.com/tailwindlabs/tailwindcss/pull/14830))
3940
- _Upgrade (experimental)_: Remove whitespace around `,` separator when print arbitrary values ([#14838](https://github.com/tailwindlabs/tailwindcss/pull/14838))

packages/@tailwindcss-postcss/src/__snapshots__/index.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
467467
font-variation-settings: inherit;
468468
letter-spacing: inherit;
469469
color: inherit;
470-
background: none;
471470
}
472471
473472
::file-selector-button {
@@ -476,7 +475,6 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
476475
font-variation-settings: inherit;
477476
letter-spacing: inherit;
478477
color: inherit;
479-
background: none;
480478
}
481479
482480
input:where(:not([type="button"], [type="reset"], [type="submit"])), select, textarea {
@@ -485,10 +483,12 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
485483
486484
button, input:where([type="button"], [type="reset"], [type="submit"]) {
487485
appearance: button;
486+
background: none;
488487
}
489488
490489
::file-selector-button {
491490
appearance: button;
491+
background: none;
492492
}
493493
494494
:-moz-focusring {

packages/tailwindcss/preflight.css

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ table {
175175
}
176176

177177
/*
178-
1. Inherit the font styles in all browsers.
179-
2. Remove the default background color.
178+
Inherit font styles in all browsers.
180179
*/
181180

182181
button,
@@ -185,12 +184,11 @@ optgroup,
185184
select,
186185
textarea,
187186
::file-selector-button {
188-
font: inherit; /* 1 */
189-
font-feature-settings: inherit; /* 1 */
190-
font-variation-settings: inherit; /* 1 */
191-
letter-spacing: inherit; /* 1 */
192-
color: inherit; /* 1 */
193-
background: transparent; /* 2 */
187+
font: inherit;
188+
font-feature-settings: inherit;
189+
font-variation-settings: inherit;
190+
letter-spacing: inherit;
191+
color: inherit;
194192
}
195193

196194
/*
@@ -204,12 +202,15 @@ textarea {
204202
}
205203

206204
/*
207-
Correct the inability to style the border radius in iOS Safari.
205+
1. Remove the default background color of buttons by default.
206+
2. Correct the inability to style the border radius in iOS Safari.
208207
*/
208+
209209
button,
210210
input:where([type='button'], [type='reset'], [type='submit']),
211211
::file-selector-button {
212-
appearance: button;
212+
background: transparent; /* 1 */
213+
appearance: button; /* 2 */
213214
}
214215

215216
/*

0 commit comments

Comments
 (0)