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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- _Experimental_: Add `@container-size` utility ([#18901](https://github.com/tailwindlabs/tailwindcss/pull/18901))

### Fixed

- Allow trailing dash in functional utility names for backwards compatibility ([#19696](https://github.com/tailwindlabs/tailwindcss/pull/19696))

## [4.2.0] - 2026-02-18

### Added
Expand Down
34 changes: 33 additions & 1 deletion packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28428,7 +28428,7 @@ describe('custom utilities', () => {
test.each([
['foo', false], // Simple name, missing '-*' suffix
['foo-*', true], // Simple name
['foo--*', false], // Root should not end in `-`
['foo--*', true], // Root ending in `-` is valid (e.g. `border--*`)
['-foo-*', true], // Simple name (negative)
['foo-bar-*', true], // With dashes
['foo_bar-*', true], // With underscores
Expand Down Expand Up @@ -28900,6 +28900,38 @@ describe('custom utilities', () => {
expect(await compileCss(input, ['tab-3', 'tab-gitlab'])).toEqual('')
})

test('functional utility with double-dash separator', async () => {
let input = css`
@theme reference {
--color-border-0: #e5e7eb;
--color-border-1: #d1d5db;
--color-border-2: #9ca3af;
}

@utility border--* {
border-color: --value(--color-border-*, [color]);
}

@tailwind utilities;
`

expect(await compileCss(input, ['border--0', 'border--1', 'border--2']))
.toMatchInlineSnapshot(`
".border--0 {
border-color: var(--color-border-0, #e5e7eb);
}

.border--1 {
border-color: var(--color-border-1, #d1d5db);
}

.border--2 {
border-color: var(--color-border-2, #9ca3af);
}"
`)
expect(await compileCss(input, ['border--3'])).toEqual('')
})

test('resolving values from `@theme`, with `--tab-size-*` syntax', async () => {
let input =
// Explicitly not using the css tagged template literal so that
Expand Down
21 changes: 10 additions & 11 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6659,22 +6659,21 @@ export function isValidFunctionalUtilityName(name: string): boolean {
let root = match[0]
let value = name.slice(root.length)

// Root should not end in `-` if there is no value
//
// `tab-size--*`
// --------- Root
// -- Suffix
//
// Because with default values, this could match `tab-size-` which is invalid.
if (value.length === 0 && root.endsWith('-')) {
return false
}

// No remaining value is valid
//
// `tab-size-*`
// -------- Root
// -- Suffix
//
// Backwards compatibility: a root ending in `-` was valid and correctly
// scanned by Oxide. This means that custom utilities can result in candidates
// such as `foo--bar`.
//
// We might want to revisit this for Tailwind CSS v5, but for now we have to
// make it backwards compatible.
//
// PR: https://github.com/tailwindlabs/tailwindcss/pull/19696
//
if (value.length === 0) {
return true
}
Expand Down