Skip to content

Commit bcddc81

Browse files
authored
Replace outline-none with outline-hidden, add new outline-none (#14926)
This PR renames the existing `outline-none` utility to `outline-hidden`, and adds a new simpler `outline-none` utility that just sets `outline-style: none`. The existing `outline-none` utility doesn't actually set `outline: none`, and instead creates a 2px invisible outline: ```css .outline-none { outline: 2px solid transparent; outline-offset: 2px; } ``` We implemented it this way because people often use `outline: none` to hide focus rings and replace them with custom shadow-based focus rings, without realizing that that approach leads to no visible focus ring in forced colors mode because box shadows aren't rendered in forced colors mode. While this is sort of helpful and clever, it can be a pain when you really do need `outline: none`, and I think it feels surprising in hindsight to hijack the name of an existing CSS property value and make it mean something else. The name `outline-hidden` feels better because it's a new keyword that CSS doesn't use for outlines, and implies that perhaps there's a bit more going on than just setting `outline-style: none`. This PR includes a codemod to convert any existing use of `outline-none` to `outline-hidden`, and we will be sure to explain what `outline-hidden` does for you in the v4 documentation. Manually tested this in the Vite playground to make sure it behaves as expected 👍 --------- Co-authored-by: Adam Wathan <[email protected]>
1 parent c72c83f commit bcddc81

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6161
- Rename `--letter-spacing-*` variables to `--tracking-*` ([#14921](https://github.com/tailwindlabs/tailwindcss/pull/14921))
6262
- Rename `--line-height-*` variables to `--leading-*` ([#14925](https://github.com/tailwindlabs/tailwindcss/pull/14925))
6363
- Revert specificity of `*` variant to match v3 behavior ([#14920](https://github.com/tailwindlabs/tailwindcss/pull/14920))
64+
- Replace `outline-none` with `outline-hidden`, add new simplified `outline-none` utility ([#14926](https://github.com/tailwindlabs/tailwindcss/pull/14926))
6465

6566
## [4.0.0-alpha.31] - 2024-10-29
6667

packages/@tailwindcss-upgrade/src/template/codemods/simple-legacy-classes.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ test.each([
3232

3333
['blur', 'blur-sm'],
3434
['blur-sm', 'blur-xs'],
35+
36+
['focus:outline-none', 'focus:outline-hidden'],
3537
])('%s => %s', async (candidate, result) => {
3638
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss";', {
3739
base: __dirname,

packages/@tailwindcss-upgrade/src/template/codemods/simple-legacy-classes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const LEGACY_CLASS_MAP = {
3030

3131
blur: 'blur-sm',
3232
'blur-sm': 'blur-xs',
33+
34+
'outline-none': 'outline-hidden',
3335
}
3436

3537
const SEEDED = new WeakSet<DesignSystem>()

packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4561,6 +4561,7 @@ exports[`getClassList 1`] = `
45614561
"outline-dashed",
45624562
"outline-dotted",
45634563
"outline-double",
4564+
"outline-hidden",
45644565
"outline-inherit",
45654566
"outline-inherit/0",
45664567
"outline-inherit/5",

packages/tailwindcss/src/utilities.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14355,11 +14355,6 @@ test('outline', async () => {
1435514355
--color-red-500: #ef4444;
1435614356
}
1435714357
14358-
.outline-none {
14359-
outline-offset: 2px;
14360-
outline: 2px solid #0000;
14361-
}
14362-
1436314358
.outline {
1436414359
outline-style: var(--tw-outline-style);
1436514360
outline-width: 1px;
@@ -14469,6 +14464,11 @@ test('outline', async () => {
1446914464
outline-style: double;
1447014465
}
1447114466
14467+
.outline-none {
14468+
--tw-outline-style: none;
14469+
outline-style: none;
14470+
}
14471+
1447214472
.outline-solid {
1447314473
--tw-outline-style: solid;
1447414474
outline-style: solid;

packages/tailwindcss/src/utilities.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3704,14 +3704,18 @@ export function createUtilities(theme: Theme) {
37043704
return atRoot([property('--tw-outline-style', 'solid', '<custom-ident>')])
37053705
}
37063706

3707-
staticUtility('outline-none', [
3707+
staticUtility('outline-hidden', [
37083708
['outline', '2px solid transparent'],
37093709
['outline-offset', '2px'],
37103710
])
37113711

37123712
/**
37133713
* @css `outline-style`
37143714
*/
3715+
staticUtility('outline-none', [
3716+
['--tw-outline-style', 'none'],
3717+
['outline-style', 'none'],
3718+
])
37153719
staticUtility('outline-solid', [
37163720
['--tw-outline-style', 'solid'],
37173721
['outline-style', 'solid'],
@@ -3939,9 +3943,7 @@ export function createUtilities(theme: Theme) {
39393943
),
39403944
decl(
39413945
'letter-spacing',
3942-
options['--tracking']
3943-
? `var(--tw-tracking, ${options['--tracking']})`
3944-
: undefined,
3946+
options['--tracking'] ? `var(--tw-tracking, ${options['--tracking']})` : undefined,
39453947
),
39463948
decl(
39473949
'font-weight',

0 commit comments

Comments
 (0)