Commit b4db3b9
Add scrollbar-width and scrollbar-color utilities (#19981)
## Summary
Adds utilities for the
[`scrollbar-width`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/scrollbar-width)
and
[`scrollbar-color`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/scrollbar-color)
CSS properties.
### `scrollbar-width`
Three static utilities mirroring the spec keywords:
| Class | CSS |
| --- | --- |
| `scrollbar-auto` | `scrollbar-width: auto;` |
| `scrollbar-thin` | `scrollbar-width: thin;` |
| `scrollbar-none` | `scrollbar-width: none;` |
### `scrollbar-color`
The `scrollbar-color` property takes two colors (thumb and track). To
allow them to be set independently, two color utilities are added that
share a pair of CSS variables (`--tw-scrollbar-thumb` and
`--tw-scrollbar-track`), following the same pattern as the gradient stop
utilities (`from-*` / `via-*` / `to-*`):
| Class | CSS |
| --- | --- |
| `scrollbar-thumb-<color>` | `--tw-scrollbar-thumb: <color>;
scrollbar-color: var(--tw-scrollbar-thumb) var(--tw-scrollbar-track);` |
| `scrollbar-track-<color>` | `--tw-scrollbar-track: <color>;
scrollbar-color: var(--tw-scrollbar-thumb) var(--tw-scrollbar-track);` |
Both go through `colorUtility`, so they automatically support the
standard color palette, theme keys (`--scrollbar-thumb-color` /
`--scrollbar-track-color` with `--color` as a fallback), arbitrary
values, and the `/<alpha>` opacity modifier. The variables are
registered with `@property` (initial value `#0000`), matching the
gradient-stop convention so an unset side falls back to transparent.
```html
<div class="scrollbar-thin scrollbar-thumb-red-500 scrollbar-track-zinc-200">…</div>
```
## Test plan
- [x] `pnpm test` (all 4480 tests pass)
- [x] New `scrollbar-width`, `scrollbar-thumb`, and `scrollbar-track`
test cases in `utilities.test.ts` covering palette colors, theme-key
colors, `current` / `inherit` / `transparent`, arbitrary colors,
`/<alpha>` modifiers, and invalid candidates
- [x] `intellisense.test.ts` snapshot updated to include the new class
names
---
_Generated by [Claude
Code](https://claude.ai/code/session_014ajg5maQ4gUHKmqBs5o7vD)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>1 parent 08cad84 commit b4db3b9
5 files changed
Lines changed: 444 additions & 1 deletion
File tree
- packages/tailwindcss/src
- __snapshots__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
Lines changed: 135 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11013 | 11013 | | |
11014 | 11014 | | |
11015 | 11015 | | |
| 11016 | + | |
| 11017 | + | |
| 11018 | + | |
| 11019 | + | |
| 11020 | + | |
| 11021 | + | |
| 11022 | + | |
| 11023 | + | |
| 11024 | + | |
| 11025 | + | |
| 11026 | + | |
| 11027 | + | |
| 11028 | + | |
| 11029 | + | |
| 11030 | + | |
| 11031 | + | |
| 11032 | + | |
| 11033 | + | |
| 11034 | + | |
| 11035 | + | |
| 11036 | + | |
| 11037 | + | |
| 11038 | + | |
| 11039 | + | |
| 11040 | + | |
| 11041 | + | |
| 11042 | + | |
| 11043 | + | |
| 11044 | + | |
| 11045 | + | |
| 11046 | + | |
| 11047 | + | |
| 11048 | + | |
| 11049 | + | |
| 11050 | + | |
| 11051 | + | |
| 11052 | + | |
| 11053 | + | |
| 11054 | + | |
| 11055 | + | |
| 11056 | + | |
| 11057 | + | |
| 11058 | + | |
| 11059 | + | |
| 11060 | + | |
| 11061 | + | |
| 11062 | + | |
| 11063 | + | |
| 11064 | + | |
| 11065 | + | |
| 11066 | + | |
| 11067 | + | |
| 11068 | + | |
| 11069 | + | |
| 11070 | + | |
| 11071 | + | |
| 11072 | + | |
| 11073 | + | |
| 11074 | + | |
| 11075 | + | |
| 11076 | + | |
| 11077 | + | |
| 11078 | + | |
| 11079 | + | |
| 11080 | + | |
| 11081 | + | |
| 11082 | + | |
| 11083 | + | |
| 11084 | + | |
| 11085 | + | |
| 11086 | + | |
| 11087 | + | |
| 11088 | + | |
| 11089 | + | |
| 11090 | + | |
| 11091 | + | |
| 11092 | + | |
| 11093 | + | |
| 11094 | + | |
| 11095 | + | |
| 11096 | + | |
| 11097 | + | |
| 11098 | + | |
| 11099 | + | |
| 11100 | + | |
| 11101 | + | |
| 11102 | + | |
| 11103 | + | |
| 11104 | + | |
| 11105 | + | |
| 11106 | + | |
| 11107 | + | |
| 11108 | + | |
| 11109 | + | |
| 11110 | + | |
| 11111 | + | |
| 11112 | + | |
| 11113 | + | |
| 11114 | + | |
| 11115 | + | |
| 11116 | + | |
| 11117 | + | |
| 11118 | + | |
| 11119 | + | |
| 11120 | + | |
| 11121 | + | |
| 11122 | + | |
| 11123 | + | |
| 11124 | + | |
| 11125 | + | |
| 11126 | + | |
| 11127 | + | |
| 11128 | + | |
| 11129 | + | |
| 11130 | + | |
| 11131 | + | |
| 11132 | + | |
| 11133 | + | |
| 11134 | + | |
| 11135 | + | |
| 11136 | + | |
| 11137 | + | |
| 11138 | + | |
| 11139 | + | |
| 11140 | + | |
| 11141 | + | |
| 11142 | + | |
| 11143 | + | |
| 11144 | + | |
| 11145 | + | |
| 11146 | + | |
| 11147 | + | |
| 11148 | + | |
| 11149 | + | |
| 11150 | + | |
11016 | 11151 | | |
11017 | 11152 | | |
11018 | 11153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
0 commit comments