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 @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Use `default` export condition for `@tailwindcss/vite` ([#18948](https://github.com/tailwindlabs/tailwindcss/pull/18948))
- Re-throw errors from PostCSS nodes ([#18373](https://github.com/tailwindlabs/tailwindcss/pull/18373))
- Detect classes in markdown inline directives ([#18967](https://github.com/tailwindlabs/tailwindcss/pull/18967))
- Ensure files with only `@theme` produce no output when built ([#18979](https://github.com/tailwindlabs/tailwindcss/pull/18979))

## [4.1.13] - 2025-09-03

Expand Down
14 changes: 14 additions & 0 deletions packages/tailwindcss/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5965,4 +5965,18 @@ describe('feature detection', () => {
expect(compiler.features & Features.AtImport).toBeTruthy()
expect(compiler.features & Features.Utilities).toBeFalsy()
})

test('using `@theme`', async () => {
let compiler = await compile(css`
@theme {
--tracking-narrower: -0.02em;
}
`)

// We see @theme
expect(compiler.features & Features.AtTheme).toBeTruthy()

// And this produces no output because no other CSS is present
expect(compiler.build([])).toEqual('')
})
})
5 changes: 5 additions & 0 deletions packages/tailwindcss/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export const enum Features {

// `@variant` was used
Variants = 1 << 5,

// `@theme` was used
AtTheme = 1 << 6,
}

async function parseCss(
Expand Down Expand Up @@ -540,6 +543,8 @@ async function parseCss(
if (node.name === '@theme') {
let [themeOptions, themePrefix] = parseThemeOptions(node.params)

features |= Features.AtTheme

if (context.reference) {
themeOptions |= ThemeOptions.REFERENCE
}
Expand Down