Skip to content

Commit 29b1eeb

Browse files
authored
feat!: v4 support (#32)
* feat!: v4 support * docs: enhance v4
1 parent 391b317 commit 29b1eeb

File tree

9 files changed

+510
-1093
lines changed

9 files changed

+510
-1093
lines changed

README.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77

88
Tailwind plugin for hide scrollbars, although the element can still be scrolled if the element's content overflows.
99

10-
<img src="https://user-images.githubusercontent.com/12596485/142972957-272010d3-29f6-4be7-99e1-dd03e7a8b92b.gif" alt="tailwind-scrollbar-hide animation demo" height="500" />
10+
<img src="https://user-images.githubusercontent.com/12596485/142972957-272010d3-29f6-4be7-99e1-dd03e7a8b92b.gif" alt="tailwind-scrollbar-hide animation demo" width="400" />
1111

1212
[🕹 Live Playground](https://reslear.github.io/tailwind-scrollbar-hide/)
1313

1414
## Features
1515

16-
🎨 Tailwind v2.x, v3.x, v4.x
16+
🎨 Tailwind v4.x, v3.x, v2.x.
17+
18+
📦 Zero dependencies
1719

1820
🛠️ Port for [unocss-preset-scrollbar-hide](https://github.com/reslear/unocss-preset-scrollbar-hide)
1921

20-
![Firefox >=64 Chrome >= 2 Safari >= 4 Internet Explorer >= 10 ](https://badges.herokuapp.com/browsers?googlechrome=2&firefox=64&safari=4&iexplore=10)
22+
🎯 Pure CSS implementation for v4.x
2123

2224
## Installation
2325

@@ -27,14 +29,36 @@ Install the plugin from npm:
2729
# Using npm
2830
npm install tailwind-scrollbar-hide
2931

32+
# Using pnpm
33+
pnpm add tailwind-scrollbar-hide
34+
3035
# Using Yarn
3136
yarn add tailwind-scrollbar-hide
37+
```
3238

33-
# Using pnpm
34-
pnpm add tailwind-scrollbar-hide
39+
### Tailwind v4 support
40+
41+
![Firefox >=64 Chrome >= 2 Safari >= 4](https://badges.herokuapp.com/browsers?googlechrome=2&firefox=64&safari=4)
42+
43+
44+
For Tailwind v4, you can use the following approach in your CSS configuration file:
45+
46+
```css
47+
/* index.css */
48+
@import 'tailwindcss';
49+
@import 'tailwind-scrollbar-hide/v4';
3550
```
3651

37-
Then add the plugin to your config file:
52+
This will automatically import and configure the plugin for Tailwind v4.
53+
54+
> Note: Internet Explorer functionality has been dropped in Tailwind v4
55+
56+
### Tailwind v2.x, v3.x support
57+
58+
![Firefox >=64 Chrome >= 2 Safari >= 4 Internet Explorer >= 10](https://badges.herokuapp.com/browsers?googlechrome=2&firefox=64&safari=4&iexplore=10)
59+
60+
61+
For Tailwind v2.x and v3.x, add the plugin to your config file:
3862

3963
```js
4064
// tailwind.config.js
@@ -64,16 +88,6 @@ export default {
6488
} satisfies Config
6589
```
6690

67-
### Tailwind v4 support
68-
69-
[Use legacy configuration files](https://tailwindcss.com/docs/v4-beta#using-legacy-configuration-files) like:
70-
71-
```css
72-
/* index.css */
73-
@import 'tailwindcss';
74-
@config "../../tailwind.config.js";
75-
```
76-
7791
## Usage
7892

7993
Use in you template `scrollbar-hide` for visual hiding scrollbar
@@ -97,4 +111,4 @@ or restore default value use `scrollbar-default`
97111

98112
## License
99113

100-
[MIT](./LICENSE)
114+
[MIT](./LICENSE)

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tailwind-scrollbar-hide",
3-
"version": "2.0.0",
3+
"version": "3.0.0",
44
"description": "tailwindcss plugin for hide scrollbar",
55
"keywords": [
66
"tailwindcss",
@@ -23,21 +23,23 @@
2323
".": {
2424
"types": "./dist/index.d.ts",
2525
"default": "./dist/index.js"
26-
}
26+
},
27+
"./v4": "./src/styles.css"
2728
},
2829
"main": "dist/index.js",
2930
"types": "dist/index.d.ts",
3031
"files": [
31-
"dist"
32+
"dist",
33+
"src/styles.css"
3234
],
3335
"scripts": {
3436
"build": "tsc",
3537
"prepublishOnly": "pnpm build"
3638
},
3739
"devDependencies": {
38-
"@types/node": "^22.10.2",
39-
"tailwindcss": "3.4.17",
40-
"typescript": "5.7.2"
40+
"@types/node": "^22.15.28",
41+
"tailwindcss": "4.1.8",
42+
"typescript": "5.8.3"
4143
},
4244
"peerDependencies": {
4345
"tailwindcss": ">=3.0.0 || >= 4.0.0 || >= 4.0.0-beta.8 || >= 4.0.0-alpha.20"

playground/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"@tailwindcss/vite": "4.0.0-beta.8",
12+
"@tailwindcss/vite": "4.1.8",
1313
"tailwind-scrollbar-hide": "workspace:*",
14-
"tailwindcss": "4.0.0-beta.8"
14+
"tailwindcss": "4.1.8"
1515
},
1616
"devDependencies": {
17-
"typescript": "5.7.2",
18-
"vite": "6.0.3"
17+
"typescript": "5.8.3",
18+
"vite": "6.3.5"
1919
}
2020
}

playground/src/main.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ class LoremBlock extends HTMLElement {
1111
<h3 class="font-bold">${this.title}</h3>
1212
1313
<div class="p-4 mt-5 rounded-lg bg-gray-50">
14-
<div class="w-full overflow-auto max-h-48 ${
15-
this.hasAttribute('scroll-hide') ? 'scrollbar-hide' : ''
16-
}">
14+
<div class="w-full overflow-auto max-h-48 ${this.hasAttribute('scroll-hide') ? 'scrollbar-hide' : ''
15+
}">
1716
1817
<div class="space-y-10">
1918
<p>

playground/src/style.css

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
@import 'tailwindcss';
2-
@config '../tailwind.config.ts';
3-
4-
/* TODO: Temporary not working
5-
https://github.com/tailwindlabs/tailwindcss/discussions/13292
6-
@import '../node_modules/tailwind-scrollbar-hide/src/index.js';
7-
@import 'tailwind-scrollbar-hide';
8-
*/
2+
@import 'tailwind-scrollbar-hide/v4';
93

104
body {
115
@apply bg-gray-100;

playground/tailwind.config.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)