Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure consistent opacity for disabled form controls in all browsers #14991

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Ensure that CSS inside Svelte `<style>` blocks always run the expected Svelte processors when using the Vite extension ([#14981](https://github.com/tailwindlabs/tailwindcss/pull/14981))

### Changed

- Set `opacity: 1` on disabled form controls in Preflight to ensure consistency across all browsers ([#14991](https://github.com/tailwindlabs/tailwindcss/pull/14991))

## [4.0.0-alpha.33] - 2024-11-11

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,14 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
color: inherit;
}

::file-selector-button:where() {
Copy link
Contributor

@thecrypticace thecrypticace Nov 13, 2024

Choose a reason for hiding this comment

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

This is definitely wrong. Maybe this is a lightningcss bug? Looks like it works in Lightning's playground so we should probably work on upgrading.

Maybe split the selector in preflight temporarily to work around it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah good catch. Noticing other stuff that's kinda in this same category of fixes, like input elements get a different background color when disabled too. Not sure how far to go with this stuff, tricky.

opacity: 1;
}

:is(button, input, optgroup, select, textarea):where([disabled]) {
opacity: 1;
}

button, input:where([type="button"], [type="reset"], [type="submit"]) {
appearance: button;
background: none;
Expand Down
17 changes: 11 additions & 6 deletions packages/tailwindcss/preflight.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ table {
}

/*
Inherit font styles in all browsers.
1. Inherit font styles in all browsers.
2. Ensure the opacity of disabled controls is consistent in all browsers;
*/

button,
Expand All @@ -184,11 +185,15 @@ optgroup,
select,
textarea,
::file-selector-button {
font: inherit;
font-feature-settings: inherit;
font-variation-settings: inherit;
letter-spacing: inherit;
color: inherit;
font: inherit; /* 1 */
font-feature-settings: inherit; /* 1 */
font-variation-settings: inherit; /* 1 */
letter-spacing: inherit; /* 1 */
color: inherit; /* 1 */

&:where([disabled]) {
opacity: 1; /* 2 */
}
}

/*
Expand Down