You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: website/docs/examples.md
+39-20
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
---
2
-
sidebar_position: 3
2
+
sidebar_position: 4
3
3
---
4
+
import Tabs from '@theme/Tabs';
5
+
import TabItem from '@theme/TabItem';
4
6
5
7
# Examples
6
8
@@ -39,10 +41,11 @@ The scollbar colour utilities are inherited, so if you want to use the same colo
39
41
```
40
42
41
43
## Variants
44
+
Use the `scrollbar-hover:` and `scrollbar-thumb:` variants to apply utilties when the scrollbar's thumb is hovered or active, respectively. Note that only scrollbars that are being [styled using pseudoelements](/getting-started#preferred-strategy) will pay attention to these variants; standards-track scrollbars (like those used in FireFox exclusively and in Chrome/Edge by default) deal with hover and active states on their own.
42
45
43
-
`hover:` and `active:` variants will be honoured in most browsers, but be aware that Firefox applies its own hover and active styling instead.
44
-
45
-
All browsers are compatible with `dark:` variants.
46
+
:::warning
47
+
If you're using `tailwind-scrollbar`@v3, use the built-in `hover:` and `active:` variants instead of `scrollbar-hover:` and `scrollbar-thumb:`.
@@ -56,7 +59,7 @@ All browsers are compatible with `dark:` variants.
56
59
57
60
## Custom colours
58
61
59
-
The colour utilities can accept colours in any format Tailwind's native colour utilities like `bg-*` can, including [custom colours](https://tailwindcss.com/docs/customizing-colors#adding-additional-colors) and [arbitrary values](https://tailwindcss.com/docs/customizing-colors#arbitrary-values).
62
+
The colour utilities can accept colours in any format Tailwind's native colour utilities like `bg-*` can, including [custom colours](https://tailwindcss.com/docs/colors#customizing-your-colors) and [arbitrary values](https://tailwindcss.com/docs/adding-custom-styles#using-arbitrary-values).
@@ -100,7 +119,7 @@ When you have both a vertical and horizontal scrollbar, you'll end up with an em
100
119
101
120
## Rounded bars
102
121
103
-
*These utilities only work in `nocompatible` mode, and have no effect in Firefox. See [configuration](/getting-started#configuration).*
122
+
*These utilities only work in `nocompatible` mode, and have no effect on standards-track scrollbars. See [configuration](/getting-started#configuration).*
104
123
105
124
The `scrollbar-*-rounded-*` family of utilities can be applied to the `thumb`, `track`, or `corner` components, and work in the same was as Tailwind's native `rounded-*` utilities. Custom values and arbitrary values are permitted.
106
125
@@ -116,7 +135,7 @@ The `scrollbar-*-rounded-*` family of utilities can be applied to the `thumb`, `
116
135
117
136
## Custom sizes
118
137
119
-
*These utilities only work in `nocompatible` mode, and have no effect in Firefox. See [configuration](/getting-started#configuration).*
138
+
*These utilities only work in `nocompatible` mode, and have no effect on standards-track scrollbars. See [configuration](/getting-started#configuration).*
120
139
121
140
The `scrollbar-w-*` and `scrollbar-h-*` utilities can be used to fine-tine the width and height of scrollbars. Note that these only have effects on vertical and horizontal scrollbars, respectively, and can only be used with the `scrollbar` utility (not `scrollbar-thin`).
The lastest version of `tailwind-scrollbar` (v4) is only compatible with `tailwindcss` v4. If you're using `tailwindcss` v3, you'll need to use `tailwind-scrollbar` v3.
23
+
:::
24
+
19
25
2. Add it to the plugins array of your Tailwind config
By default, only utilities that can have expressions across browsers are available. In order to access additional utilities that may not exist in all browsers, like [rounding](/examples#rounded-bars) and [custom sizes](/examples#custom-sizes), you can add the `nocompatible` flag to the configuration. You may need to also set the [preferred strategy](#preferredstrategy) to `pseudoelements` for `nocompatible` utilities to take effect in newer browsers.
The default scrollbar strategy used by the plugin is to prefer the standards-track properties (`scrollbar-width` and `scrollbar-color`) and fall back to pseudoelements only when standards-track properties are not supported. Although this strategy is encouraged, it does have drawbacks: available features are limited compared to the pseudoelement strategy, and some browser/OS combinations ignore scrollbar properties entirely. If you'd prefer to default to the pseudoelement strategy instead, pass `preferredStrategy: 'pseudoelements'` to the plugin configuration. Note that since Firefox does not support pseudoelements at all, it will continue to use standards-track properties.
`tailwind-scrollbar@^4.0.0` supports Tailwindcss v4, but there are some **breaking changes** to be aware of.
8
+
9
+
### `hover:` and `active:`
10
+
11
+
In v3, hover and active variants could be applied with Tailwind's built-in `hover:` and `active:` (e.g. `hover:scrollbar-thumb-red-100`). In v4, this has different, arguably more predictable, semantics: an element with `hover:scrollbar-thumb-red-100` will cause its scrollbar's thumb to change colour when the **element** is hovered, not the scrollbar's thumb.
12
+
13
+
Let's be honest, though, that's probably not what you're after. To apply variants just to the scrollbar's thumb, use `scrollbar-hover:` and `scrollbar-active:`. If, for some reason, you're wanting to apply these variants to the track or corner elements, `scrollbar-track-hover:`, `scrollbar-track-active:`, `scrollbar-corner-hover:`, and `scrollbar-corner-active:` are there for you.
14
+
15
+
**In most cases, globally replacing `hover:scrollbar` with `scrollbar-hover:scrollbar` and `active:scrollbar` with `scrollbar-active:scrollbar` should be enough.**
Copy file name to clipboardexpand all lines: website/docs/utilities.md
+18-5
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
-
sidebar_position: 4
2
+
sidebar_position: 5
3
3
---
4
4
5
-
# Complete list of utilities
5
+
# Complete list of utilities/variants
6
6
7
7
## Base utilities
8
8
These utilities initialize scrollbar styling. You always need one of them, even if you're using custom widths.
@@ -22,10 +22,8 @@ All of the asterisks can be replaced [with any tailwind colour](https://tailwind
22
22
| <spanclassName="whitespace-nowrap">`scrollbar-track-*`</span> | Sets the colour of the scrollbar track ||
23
23
| <spanclassName="whitespace-nowrap">`scrollbar-corner-*`</span> | Sets the colour of the scrollbar corner | The corner will only appear if you have both vertical and horizontal scrollbars. |
24
24
25
-
Additionally, `hover:` and `active:`[variants](https://tailwindcss.com/docs/hover-focus-and-other-states#hover-focus-and-active) may be used, but they will be ignored by Firefox since it defines these styles itself.
26
-
27
25
## Nocompatible utilities
28
-
These styles are only available in [`nocompatible` mode](/getting-started#configuration). They won't have any effect in Firefox.
26
+
These styles are only available in [`nocompatible` mode](/getting-started#configuration). They won't have any effect on standards-track scrollbars, such as those used by Firefox or by Chrome/Edge by default.
29
27
30
28
| Utility | Effect | Notes |
31
29
|-------------|--------|-------|
@@ -35,3 +33,18 @@ These styles are only available in [`nocompatible` mode](/getting-started#config
35
33
| <spanclassName="whitespace-nowrap">`scrollbar-track-rounded-*`</span> | Rounds a scrollbar track's corners | See above, but for the track |
36
34
| <spanclassName="whitespace-nowrap">`scrollbar-corner-rounded-*`</span> | Rounds a scrollbar corner's corners | See above, but for the corner pseudoelement created when both horizontal and vertial scrollbars are present |
37
35
36
+
## Variants
37
+
38
+
:::warning
39
+
These variants are not available in `tailwind-scrollbar`@v3. Use the built-in `hover:` and `active:` instead.
40
+
:::
41
+
42
+
These variants don't have any effect on standards-track scrollbars, such as those used by Firefox or by Chrome/Edge by default. The responsibility of styling hover and active states is assumed by the browser in that scenario.
0 commit comments