Transition outline-color (#15690)

This PR adds `outline-color` to the transition-property again, and
updates the implementation for `outline-hidden`.

The `outline-hidden` will behave exactly the same as `outline-none`
_except_ in forced colors mode. In forced colors mode, `outline-hidden`
will force a 2px solid border.

Closes: #15591
This commit is contained in:
Robin Malfait 2025-01-21 11:02:57 -05:00 committed by GitHub
parent d65bb68d16
commit 4820f6bff8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 32 additions and 12 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Add new `@variant` directive for applying variants to your CSS ([#15663](https://github.com/tailwindlabs/tailwindcss/pull/15663))
- Include `outline-color` when transitioning colors ([#15690](https://github.com/tailwindlabs/tailwindcss/pull/15690))
### Fixed
@ -27,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Use more modern `--alpha(color / 50%)` syntax instead of `--alpha(color, 50%)` ([#15665](https://github.com/tailwindlabs/tailwindcss/pull/15665))
- Rename `@variant` to `@custom-variant` ([#15663](https://github.com/tailwindlabs/tailwindcss/pull/15663))
- `outline-hidden` and `outline-none` behave the same in non-forced colors mode ([#15690](https://github.com/tailwindlabs/tailwindcss/pull/15690))
## [4.0.0-beta.9] - 2025-01-09

View File

@ -1019,8 +1019,9 @@ export default {
none: 'none',
all: 'all',
DEFAULT:
'color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
colors: 'color, background-color, border-color, text-decoration-color, fill, stroke',
'color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
colors:
'color, background-color, border-color, outline-color, text-decoration-color, fill, stroke',
opacity: 'opacity',
shadow: 'box-shadow',
transform: 'transform',

View File

@ -13873,7 +13873,7 @@ test('transition', async () => {
}
.transition {
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter;
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter;
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
transition-duration: var(--tw-duration, var(--default-transition-duration));
}
@ -13891,7 +13891,7 @@ test('transition', async () => {
}
.transition-colors {
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
transition-duration: var(--tw-duration, var(--default-transition-duration));
}
@ -13940,7 +13940,7 @@ test('transition', async () => {
}
.transition {
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter;
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter;
transition-timing-function: var(--tw-ease, ease);
transition-duration: var(--tw-duration, .1s);
}
@ -13952,7 +13952,7 @@ test('transition', async () => {
}
.transition-colors {
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
transition-timing-function: var(--tw-ease, ease);
transition-duration: var(--tw-duration, .1s);
}"
@ -14543,6 +14543,7 @@ test('outline', async () => {
`,
[
'outline',
'outline-hidden',
// outline-style
'outline-none',
@ -14594,6 +14595,17 @@ test('outline', async () => {
--color-red-500: #ef4444;
}
.outline-hidden {
outline-style: none;
}
@media (forced-colors: active) {
.outline-hidden {
outline-offset: 2px;
outline: 2px solid #0000;
}
}
.outline {
outline-style: var(--tw-outline-style);
outline-width: 1px;

View File

@ -3552,7 +3552,7 @@ export function createUtilities(theme: Theme) {
staticUtility('transition-colors', [
[
'transition-property',
'color, background-color, border-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to',
'color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to',
],
['transition-timing-function', defaultTimingFunction],
['transition-duration', defaultDuration],
@ -3575,7 +3575,7 @@ export function createUtilities(theme: Theme) {
functionalUtility('transition', {
defaultValue:
'color, background-color, border-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter',
'color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter',
themeKeys: ['--transition-property'],
handle: (value) => [
decl('transition-property', value),
@ -3850,10 +3850,15 @@ export function createUtilities(theme: Theme) {
return atRoot([property('--tw-outline-style', 'solid')])
}
staticUtility('outline-hidden', [
['outline', '2px solid transparent'],
['outline-offset', '2px'],
])
utilities.static('outline-hidden', () => {
return [
decl('outline-style', 'none'),
atRule('@media', '(forced-colors: active)', [
decl('outline', '2px solid transparent'),
decl('outline-offset', '2px'),
]),
]
})
/**
* @css `outline-style`