Skip to content

Hide default shadow suggestions when missing theme keys #17743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 22, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -4755,28 +4755,6 @@ exports[`getClassList 1`] = `
"inset-ring-transparent/90",
"inset-ring-transparent/95",
"inset-ring-transparent/100",
"inset-shadow",
"inset-shadow/0",
"inset-shadow/5",
"inset-shadow/10",
"inset-shadow/15",
"inset-shadow/20",
"inset-shadow/25",
"inset-shadow/30",
"inset-shadow/35",
"inset-shadow/40",
"inset-shadow/45",
"inset-shadow/50",
"inset-shadow/55",
"inset-shadow/60",
"inset-shadow/65",
"inset-shadow/70",
"inset-shadow/75",
"inset-shadow/80",
"inset-shadow/85",
"inset-shadow/90",
"inset-shadow/95",
"inset-shadow/100",
"inset-shadow-current",
"inset-shadow-current/0",
"inset-shadow-current/5",
Expand Down Expand Up @@ -9685,28 +9663,6 @@ exports[`getClassList 1`] = `
"sepia-0",
"sepia-50",
"sepia-100",
"shadow",
"shadow/0",
"shadow/5",
"shadow/10",
"shadow/15",
"shadow/20",
"shadow/25",
"shadow/30",
"shadow/35",
"shadow/40",
"shadow/45",
"shadow/50",
"shadow/55",
"shadow/60",
"shadow/65",
"shadow/70",
"shadow/75",
"shadow/80",
"shadow/85",
"shadow/90",
"shadow/95",
"shadow/100",
"shadow-current",
"shadow-current/0",
"shadow-current/5",
Expand Down Expand Up @@ -10157,28 +10113,6 @@ exports[`getClassList 1`] = `
"text-nowrap",
"text-pretty",
"text-right",
"text-shadow",
"text-shadow/0",
"text-shadow/5",
"text-shadow/10",
"text-shadow/15",
"text-shadow/20",
"text-shadow/25",
"text-shadow/30",
"text-shadow/35",
"text-shadow/40",
"text-shadow/45",
"text-shadow/50",
"text-shadow/55",
"text-shadow/60",
"text-shadow/65",
"text-shadow/70",
"text-shadow/75",
"text-shadow/80",
"text-shadow/85",
"text-shadow/90",
"text-shadow/95",
"text-shadow/100",
"text-shadow-current",
"text-shadow-current/0",
"text-shadow-current/5",
Expand Down
30 changes: 30 additions & 0 deletions packages/tailwindcss/src/intellisense.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,33 @@ test('Theme keys with underscores are suggested with underscores', async () => {
expect(entries).not.toContainEqual(['p-2_5', { modifiers: [] }])
expect(entries).not.toContainEqual(['p-logo.margin', { modifiers: [] }])
})

test('shadow utility default suggestions', async () => {
let input = css`
@theme {
/* nothing */
}
`

let design = await __unstable__loadDesignSystem(input)
let classNames = design.getClassList().map(([name]) => name)

expect(classNames).not.toContain('shadow')
expect(classNames).not.toContain('inset-shadow')
expect(classNames).not.toContain('text-shadow')

input = css`
@theme {
--shadow: 0 0 0 solid black;
--text-shadow: 0 0 0 solid black;
--inset-shadow: 0 0 0 solid black;
}
`

design = await __unstable__loadDesignSystem(input)
classNames = design.getClassList().map(([name]) => name)

expect(classNames).toContain('shadow')
expect(classNames).toContain('inset-shadow')
expect(classNames).toContain('text-shadow')
})
6 changes: 3 additions & 3 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5182,7 +5182,7 @@ export function createUtilities(theme: Theme) {
{
valueThemeKeys: ['--text-shadow'],
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
hasDefaultValue: true,
hasDefaultValue: theme.get(['--text-shadow']) !== null,
},
])

Expand Down Expand Up @@ -5335,7 +5335,7 @@ export function createUtilities(theme: Theme) {
{
valueThemeKeys: ['--shadow'],
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
hasDefaultValue: true,
hasDefaultValue: theme.get(['--shadow']) !== null,
},
])

Expand Down Expand Up @@ -5462,7 +5462,7 @@ export function createUtilities(theme: Theme) {
{
valueThemeKeys: ['--inset-shadow'],
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
hasDefaultValue: true,
hasDefaultValue: theme.get(['--inset-shadow']) !== null,
},
])

Expand Down