Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add scrollbar-none, scrollbar-thin, scrollbar-width-auto utilities
  • Loading branch information
lukewarlow committed Jan 23, 2025
commit 966177d6fb54239d3848667cce1dfe517f82780e
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet
### Added

- Add utilities for the `scrollbar-width` CSS property ([#14183](https://github.com/tailwindlabs/tailwindcss/pull/14183))

## [4.0.0] - 2025-01-21
## [4.0.0-beta.10] - 2025-01-21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6600,6 +6600,9 @@ exports[`getClassList 1`] = `
"scroll-py-96",
"scroll-py-px",
"scroll-smooth",
"scrollbar-none",
"scrollbar-thin",
"scrollbar-width-auto",
"select-all",
"select-auto",
"select-none",
Expand Down
29 changes: 29 additions & 0 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8673,6 +8673,35 @@ test('scroll-behavior', async () => {
).toEqual('')
})

test('scrollbar-width', async () => {
expect(await run(['scrollbar-width-auto', 'scrollbar-thin', 'scrollbar-none']))
.toMatchInlineSnapshot(`
".scrollbar-none {
scrollbar-width: none;
}

.scrollbar-none::-webkit-scrollbar {
display: none;
}

.scrollbar-thin {
scrollbar-width: thin;
}

.scrollbar-width-auto {
scrollbar-width: auto;
}"
`)
expect(
await run([
'scrollbar-width-none',
'scrollbar-width-thin',
'-scrollbar-none',
'scrollbar-none/foo',
]),
).toEqual('')
})

test('truncate', async () => {
expect(await run(['truncate'])).toMatchInlineSnapshot(`
".truncate {
Expand Down
7 changes: 7 additions & 0 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,13 @@ export function createUtilities(theme: Theme) {
staticUtility('scroll-auto', [['scroll-behavior', 'auto']])
staticUtility('scroll-smooth', [['scroll-behavior', 'smooth']])

staticUtility('scrollbar-width-auto', [['scrollbar-width', 'auto']])
staticUtility('scrollbar-thin', [['scrollbar-width', 'thin']])
staticUtility('scrollbar-none', [
['scrollbar-width', 'none'],
() => styleRule('&::-webkit-scrollbar', [decl('display', 'none')]),
])

staticUtility('truncate', [
['overflow', 'hidden'],
['text-overflow', 'ellipsis'],
Expand Down