Skip to content

Resolves text-[--spacing(n)] as color instead of font-size #20258

Closed

Description

@RobinMalfait

Discussed in #20257

Originally posted by marcjulian June 18, 2026

What version of Tailwind CSS are you using?

For example: v4.3.0, v4.3.1

What build tool (or framework if it abstracts the build tool) are you using?

For example: @tailwindcss/postcss 4.3.1, postcss 8.5.15, Angular v22

What version of Node.js are you using?

For example: v24.15.0

What browser are you using?

For example: Chrome, Firefox

What operating system are you using?

For example: macOS

Reproduction URL

Show casing the generated classes in TailwindPlay and a playground repository from spartan/ui for example in the hlm-spinner component uses the longer class name.

Describe your issue

Using the arbitrary value syntax text-[--spacing(n)] to align font sizes with the spacing scale, to mimic size-4, resolves the class as color rather than font-size property.

This issue came up while porting shadcn styles to Angular spartan/ui using ng-icon. The icon sizes follows the font size, thus we need to replace size-4 with text-[--spacing(4)].

Angular template

<ng-icon name="lucideLoader2 class="text-[--spacing(8)]" />

Generated CSS - validate in the TailwindPlay

.text-\[--spacing\(8\)\] {
  color: calc(var(--spacing) * 8);
}

Expected Generated CSS - text- util can be used for colors but also for font-size and expected it to produce

.text-\[--spacing\(8\)\] {
  font-size: calc(var(--spacing) * 8);
}

As an alternative, we use text-[calc(var(--spacing)*4)] directly using var(--spacing) and not the --spacing(4) function. This resolves to a class with font-size property.

.text-\[calc\(var\(--spacing\)\*8\)\] {
  font-size: calc(var(--spacing) * 8);
}

Another alternative class could be text-[calc(--spacing(4))], included in the TailwindPlay, which resolves also to font-size property, but includes the calc from the arbitrary syntax and additionally from the --spacing() function.

.text-\[calc\(--spacing\(8\)\)\] {
  font-size: calc(calc(var(--spacing) * 8));
}

Tailwind CSS IntelliSense

When using the alternative class text-[calc(var(--spacing)*4)] and Tailwind CSS IntelliSense is installed in VSCode, it suggest to replace the class with the shorter version text-[--spacing(4)].

Suggestion Image
Quick Fix Image
IntelliSense for `text-[calc(var(--spacing)*4)]` Image
IntelliSense for `text-[--spacing(4)]` Image

Activity

  1. RobinMalfait commented on Jun 18, 2026

    @RobinMalfait
    ContributorAuthor

    Oops I was a bit too fast to close this, sorry @marcjulian.

    Typically when there is a conflict, then you can use a data type to resolve the ambiguity. In this case, that would be using text-[length:--spacing(4)] (docs: https://tailwindcss.com/docs/font-size#using-a-custom-value)

    But since this works with the calc(…) and not with the --spacing(…), then that's definitely a bug. Will fix this. In the meantime, if you use text-[length:--spacing(4)] then you can temporarily resolve your issue.

  2. self-assigned this
    on Jun 18, 2026
  3. marcjulian commented on Jun 18, 2026

    @marcjulian

    No worries @RobinMalfait for closing it. I also wasn't sure if it is a bug or more a discussion.

    Thanks for pointing out how to avoid a conflict with data type ambiguity. Awesome thank your for your suggestion text-[length:--spacing(4)], this class also removes the IntelliSense suggestion .

  4. RobinMalfait commented on Jun 18, 2026

    @RobinMalfait
    ContributorAuthor

    @marcjulian This should be fixed by #20260, and will be available in the next release.
    You can already try it by using the insiders build:
    CLI:

    npm install tailwindcss@insiders @tailwindcss/cli@insiders

    PostCSS:

    npm install tailwindcss@insiders @tailwindcss/postcss@insiders

    Vite:

    npm install tailwindcss@insiders @tailwindcss/vite@insiders

    webpack:

    npm install tailwindcss@insiders @tailwindcss/webpack@insiders
  5. added a commit that references this issue on Jun 18, 2026
    c46f654
  6. marcjulian commented on Jun 18, 2026

    @marcjulian

    Thank you for the quick fix @RobinMalfait! The property is now correctly resolving to font-size in the insider build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions