Skip to content

Show warning when using unsupported bare value data type #17464

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 7 commits into from
Apr 4, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
list all allowed bare value data types
  • Loading branch information
RobinMalfait committed Apr 3, 2025
commit 7b4a7735fd7728a3dae0b4f9e28b0d56c1bc682d
17 changes: 11 additions & 6 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5692,6 +5692,16 @@ export function createUtilities(theme: Theme) {
return utilities
}

// Only allowed bare value data types, to prevent creating new syntax that we
// typically don't support right now. E.g.: `--value(color)` would allow you to
// use `text-#0088cc` as a valid utility, which is not what we want.
export const BARE_VALUE_DATA_TYPES = [
'number', // 2.5
'integer', // 8
'ratio', // 2/3
'percentage', // 25%
]

export function createCssUtility(node: AtRule) {
let name = node.params

Expand Down Expand Up @@ -6084,12 +6094,7 @@ function resolveValueFunction(
// Limit the bare value types, to prevent new syntax that we
// don't want to support. E.g.: `text-#000` is something we
// don't want to support, but could be built this way.
if (
arg.value !== 'number' &&
arg.value !== 'integer' &&
arg.value !== 'ratio' &&
arg.value !== 'percentage'
) {
if (!BARE_VALUE_DATA_TYPES.includes(arg.value)) {
continue
}

Expand Down