Skip to content

Commit 7b03aca

Browse files
Replace deprecated clip with clip-path in sr-only (#18769)
## Summary This PR replaces the deprecated `clip` property used in the `sr-only` utility with `clip-path`, and updates the corresponding reset in `not-sr-only`. - Closes [#18768](#18768) - Replaces `clip: rect(0, 0, 0, 0);` with `clip-path: inset(50%);` in `sr-only` - Replaces `clip: auto;` with `clip-path: none;` in `not-sr-only` - Updates unit test snapshots to reflect the new CSS output Rationale: - `clip` is deprecated and flagged by modern linters; `clip-path` is the recommended modern alternative while preserving the intended visually-hidden behavior. Before: ```css .sr-only { clip: rect(0, 0, 0, 0); } .not-sr-only { clip: auto; } ``` After: ```css .sr-only { clip-path: inset(50%); } .not-sr-only { clip-path: none; } ``` --------- Co-authored-by: Jordan Pittman <[email protected]>
1 parent e578238 commit 7b03aca

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Discard matched variants with unknown named values ([#18799](https://github.com/tailwindlabs/tailwindcss/pull/18799))
1818
- Discard matched variants with non-string values ([#18799](https://github.com/tailwindlabs/tailwindcss/pull/18799))
1919
- Show suggestions for known `matchVariant` values ([#18798](https://github.com/tailwindlabs/tailwindcss/pull/18798))
20+
- Replace deprecated `clip` with `clip-path` in `sr-only` ([#18769](https://github.com/tailwindlabs/tailwindcss/pull/18769))
2021
- Upgrade: Migrate `aria` theme keys to `@custom-variant` ([#18815](https://github.com/tailwindlabs/tailwindcss/pull/18815))
2122
- Upgrade: Migrate `data` theme keys to `@custom-variant` ([#18816](https://github.com/tailwindlabs/tailwindcss/pull/18816))
2223
- Upgrade: Migrate `supports` theme keys to `@custom-variant` ([#18817](https://github.com/tailwindlabs/tailwindcss/pull/18817))

packages/tailwindcss/src/utilities.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const css = String.raw
77
test('sr-only', async () => {
88
expect(await run(['sr-only'])).toMatchInlineSnapshot(`
99
".sr-only {
10-
clip: rect(0, 0, 0, 0);
10+
clip-path: inset(50%);
1111
white-space: nowrap;
1212
border-width: 0;
1313
width: 1px;
@@ -24,7 +24,7 @@ test('sr-only', async () => {
2424
test('not-sr-only', async () => {
2525
expect(await run(['not-sr-only'])).toMatchInlineSnapshot(`
2626
".not-sr-only {
27-
clip: auto;
27+
clip-path: none;
2828
white-space: normal;
2929
width: auto;
3030
height: auto;

packages/tailwindcss/src/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ export function createUtilities(theme: Theme) {
556556
['padding', '0'],
557557
['margin', '-1px'],
558558
['overflow', 'hidden'],
559-
['clip', 'rect(0, 0, 0, 0)'],
559+
['clip-path', 'inset(50%)'],
560560
['white-space', 'nowrap'],
561561
['border-width', '0'],
562562
])
@@ -567,7 +567,7 @@ export function createUtilities(theme: Theme) {
567567
['padding', '0'],
568568
['margin', '0'],
569569
['overflow', 'visible'],
570-
['clip', 'auto'],
570+
['clip-path', 'none'],
571571
['white-space', 'normal'],
572572
])
573573

0 commit comments

Comments
 (0)