Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Don't transition `visibility` when using `transition` ([#18795](https://github.com/tailwindlabs/tailwindcss/pull/18795))
- Discard matched variants with unknown named values ([#18799](https://github.com/tailwindlabs/tailwindcss/pull/18799))
- Discard matched variants with non-string values ([#18799](https://github.com/tailwindlabs/tailwindcss/pull/18799))
- Show suggestions for known `matchVariant` values ([#18798](https://github.com/tailwindlabs/tailwindcss/pull/18798))

## [4.1.12] - 2025-08-13

Expand Down
4 changes: 4 additions & 0 deletions packages/tailwindcss/src/compat/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ export function buildPluginApi({
return aValue < zValue ? -1 : 1
},
)

designSystem.variants.suggest(name, () =>
Object.keys(options?.values ?? {}).filter((v) => v !== 'DEFAULT'),
)
},

addUtilities(utilities) {
Expand Down
37 changes: 37 additions & 0 deletions packages/tailwindcss/src/intellisense.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,3 +675,40 @@ test('Custom @utility and existing utility with names matching theme keys dont g
expect(matches).toHaveLength(1)
expect(classMap.get('text-header')?.modifiers).toEqual(['sm'])
})

test('matchVariant', async () => {
let input = css`
@import 'tailwindcss/utilities';
@plugin "./plugin.js";
`

let design = await __unstable__loadDesignSystem(input, {
loadStylesheet: async (_, base) => ({
path: '',
base,
content: '@tailwind utilities;',
}),
loadModule: async () => ({
path: '',
base: '',
module: plugin(({ matchVariant }) => {
matchVariant('foo', (val) => `&:is(${val})`, {
values: {
DEFAULT: '1',
a: 'a',
b: 'b',
},
})
}),
}),
})

let variants = design.getVariants()
let v1 = variants.find((v) => v.name === 'foo')!
expect(v1).not.toBeUndefined()

expect(v1.hasDash).toEqual(true)
expect(v1.isArbitrary).toEqual(true)
expect(v1.name).toEqual('foo')
expect(v1.values).toEqual(['a', 'b'])
})