Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ const generateScrollbarSizeUtilities = ({ preferPseudoElements }) => ({
* @param {typedefs.TailwindPlugin} tailwind - Tailwind's plugin object
*/
const addColorUtilities = ({ matchUtilities, theme }) => {
const themeColors = flattenColorPalette(theme('colors'));
const themeColors = theme('scrollbarColor') ?? theme('colors');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shadows your global colors definitions. If you've defined scrollbarColor in your config, this change would prevent you from using any colours for scrollbars that aren't a scrollbarColor.

Copy link
Owner

@adoxography adoxography Mar 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key scrollbarColor works with legacy JavaScript configs, but it won't play nicely with the CSS-based config introduced in Tailwind v4. As pointed out in #109, it's common to configure prettier to lowercase all of your CSS custom properties.

The new (undocumented) pattern Tailwind 4 is following for this is kebab-case (e.g. --border-color-neutral); so in this case, colours defined as --scrollbar-color-____ should also be recognized.

See tailwindlabs/tailwindcss#16512, tailwindlabs/tailwindcss#15757

Happily, it looks like theme('scrollbar-color') does what you hope it will - so there isn't any technical limitation here.

const colors = Object.fromEntries(
Object.entries(themeColors).map(([k, v]) => [k, toColorValue(v)])
Object.entries(flattenColorPalette(themeColors)).map(([k, v]) => [k, toColorValue(v)])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this line becomes (even more) cognitively heavy by moving flattenColorPalette into it. I'd generally prefer to assign to a different variable and leave this line alone.

);

COMPONENTS.forEach(component => {
Expand Down