Skip to content

Commit 2e1ccf7

Browse files
authored
Add scrollbar-gutter-* utilities (#20018)
This PR adds new `scrollbar-gutter-*` utilities. The API looks like this: | Class | CSS | | -- | -- | | `scrollbar-gutter-auto` | `scrollbar-gutter: auto` | | `scrollbar-gutter-stable` | `scrollbar-gutter: stable` | | `scrollbar-gutter-both` | `scrollbar-gutter: stable both-edges` |
1 parent c00da89 commit 2e1ccf7

7 files changed

Lines changed: 55 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- _Experimental_: add `@container-size` utility ([#18901](https://github.com/tailwindlabs/tailwindcss/pull/18901))
13-
- _Experimental_: add `scrollbar-{auto,thin,none}` utilities for `scrollbar-width`, and `scrollbar-thumb-*` / `scrollbar-track-*` color utilities for `scrollbar-color` ([#19981](https://github.com/tailwindlabs/tailwindcss/pull/19981))
13+
- _Experimental_: add `scrollbar-{auto,thin,none}` utilities for `scrollbar-width`, and `scrollbar-thumb-*` / `scrollbar-track-*` color utilities for `scrollbar-color` ([#19981](https://github.com/tailwindlabs/tailwindcss/pull/19981), [#20019](https://github.com/tailwindlabs/tailwindcss/pull/20019))
1414
- Allow using `@variant` with stacked variants (e.g. `@variant hover:focus { … }`) ([#19996](https://github.com/tailwindlabs/tailwindcss/pull/19996))
1515
- Allow using `@variant` with compound variants (e.g. `@variant hover, focus { … }`) ([#19996](https://github.com/tailwindlabs/tailwindcss/pull/19996))
1616
- Support `--default(…)` in `--value(…)` and `--modifier(…)` for functional `@utility` definitions ([#19989](https://github.com/tailwindlabs/tailwindcss/pull/19989))
17+
- Add `scrollbar-gutter-*` utilities ([#20018](https://github.com/tailwindlabs/tailwindcss/pull/20018))
1718

1819
### Fixed
1920

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11014,6 +11014,9 @@ exports[`getClassList 1`] = `
1101411014
"scroll-py-px",
1101511015
"scroll-smooth",
1101611016
"scrollbar-auto",
11017+
"scrollbar-gutter-auto",
11018+
"scrollbar-gutter-both",
11019+
"scrollbar-gutter-stable",
1101711020
"scrollbar-none",
1101811021
"scrollbar-thin",
1101911022
"scrollbar-thumb-current",

packages/tailwindcss/src/compat/config.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ test('Config files can affect the theme', async () => {
215215

216216
expect(pretty(compiler.build(['bg-primary', 'scrollbar-primary']))).toMatchInlineSnapshot(`
217217
"
218-
.bg-primary {
219-
background-color: #c0ffee;
220-
}
221218
.scrollbar-primary {
222219
scrollbar-color: #c0ffee;
223220
}
221+
.bg-primary {
222+
background-color: #c0ffee;
223+
}
224224
"
225225
`)
226226
})

packages/tailwindcss/src/compat/plugin-api.test.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3953,17 +3953,17 @@ describe('matchUtilities()', () => {
39533953
expect(optimizeCss(await run(['scrollbar-[2px]', 'scrollbar-[#08c]', 'scrollbar-[#08c]/50'])))
39543954
.toMatchInlineSnapshot(`
39553955
"
3956+
.scrollbar-\\[2px\\] {
3957+
scrollbar-width: 2px;
3958+
}
3959+
39563960
.scrollbar-\\[\\#08c\\] {
39573961
scrollbar-color: #08c;
39583962
}
39593963
39603964
.scrollbar-\\[\\#08c\\]\\/50 {
39613965
scrollbar-color: oklab(59.9824% -.067 -.124 / .5);
39623966
}
3963-
3964-
.scrollbar-\\[2px\\] {
3965-
scrollbar-width: 2px;
3966-
}
39673967
"
39683968
`)
39693969
expect(optimizeCss(await run(['scrollbar-[2px]/50']))).toEqual('')
@@ -4117,10 +4117,14 @@ describe('matchUtilities()', () => {
41174117
),
41184118
).toMatchInlineSnapshot(`
41194119
"
4120-
.scrollbar-2 {
4120+
.scrollbar-2, .scrollbar-\\[2px\\] {
41214121
scrollbar-width: 2px;
41224122
}
41234123
4124+
.scrollbar-\\[length\\:var\\(--my-width\\)\\] {
4125+
scrollbar-width: var(--my-width);
4126+
}
4127+
41244128
.scrollbar-\\[\\#fff\\] {
41254129
scrollbar-color: #fff;
41264130
}
@@ -4129,10 +4133,6 @@ describe('matchUtilities()', () => {
41294133
scrollbar-color: oklab(100% 0 5.96046e-8 / .5);
41304134
}
41314135
4132-
.scrollbar-\\[2px\\] {
4133-
scrollbar-width: 2px;
4134-
}
4135-
41364136
.scrollbar-\\[color\\:var\\(--my-color\\)\\], .scrollbar-\\[color\\:var\\(--my-color\\)\\]\\/50 {
41374137
scrollbar-color: var(--my-color);
41384138
}
@@ -4143,10 +4143,6 @@ describe('matchUtilities()', () => {
41434143
}
41444144
}
41454145
4146-
.scrollbar-\\[length\\:var\\(--my-width\\)\\] {
4147-
scrollbar-width: var(--my-width);
4148-
}
4149-
41504146
.scrollbar-\\[var\\(--my-color\\)\\], .scrollbar-\\[var\\(--my-color\\)\\]\\/50 {
41514147
scrollbar-color: var(--my-color);
41524148
}

packages/tailwindcss/src/property-order.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ export default [
131131
'scroll-padding-bottom',
132132
'scroll-padding-left',
133133

134+
'scrollbar-width',
135+
'scrollbar-color',
136+
'scrollbar-gutter',
137+
134138
'list-style-position',
135139
'list-style-type',
136140
'list-style-image',

packages/tailwindcss/src/utilities.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11439,6 +11439,36 @@ test('scrollbar-width', async () => {
1143911439
).toEqual('')
1144011440
})
1144111441

11442+
test('scrollbar-gutter', async () => {
11443+
expect(await run(['scrollbar-gutter-auto', 'scrollbar-gutter-stable', 'scrollbar-gutter-both']))
11444+
.toMatchInlineSnapshot(`
11445+
"
11446+
.scrollbar-gutter-auto {
11447+
scrollbar-gutter: auto;
11448+
}
11449+
11450+
.scrollbar-gutter-both {
11451+
scrollbar-gutter: stable both-edges;
11452+
}
11453+
11454+
.scrollbar-gutter-stable {
11455+
scrollbar-gutter: stable;
11456+
}
11457+
"
11458+
`)
11459+
expect(
11460+
await run([
11461+
'scrollbar-gutter',
11462+
'-scrollbar-gutter-auto',
11463+
'-scrollbar-gutter-stable',
11464+
'-scrollbar-gutter-both',
11465+
'scrollbar-gutter-auto/foo',
11466+
'scrollbar-gutter-stable/foo',
11467+
'scrollbar-gutter-both/foo',
11468+
]),
11469+
).toEqual('')
11470+
})
11471+
1144211472
test('scrollbar-thumb', async () => {
1144311473
expect(
1144411474
await compileCss(

packages/tailwindcss/src/utilities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,6 +2218,10 @@ export function createUtilities(theme: Theme) {
22182218
staticUtility('scrollbar-thin', [['scrollbar-width', 'thin']])
22192219
staticUtility('scrollbar-none', [['scrollbar-width', 'none']])
22202220

2221+
staticUtility('scrollbar-gutter-auto', [['scrollbar-gutter', 'auto']])
2222+
staticUtility('scrollbar-gutter-stable', [['scrollbar-gutter', 'stable']])
2223+
staticUtility('scrollbar-gutter-both', [['scrollbar-gutter', 'stable both-edges']])
2224+
22212225
{
22222226
let scrollbarColorProperties = () => {
22232227
return atRoot([

0 commit comments

Comments
 (0)