Skip to content
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

Add support for arbitrary properties #6161

merged 5 commits into from Nov 22, 2021


Copy link

This PR adds support for using classes that define completely arbitrary CSS property/value pairs:

<div class="[paint-order:markers]">

On its own this isn't that useful, since you could also just do this with inline styles. Where this becomes more powerful is when you combine it with modifiers like our responsive modifiers, or hover, focus, etc.

<div class="[paint-order:markers] md:[paint-order:normal]">

Inline styles don't let you use pseudo-classes or media queries, but this feature does, making it sort of like a more powerful version of inline styles.

It lets people use CSS properties Tailwind doesn't include yet with all the power you get with Tailwind's built-in utilities, which makes the user experience a lot less frustrating when you need something obscure or new that we haven't added yet.

Works with CSS variables too which is pretty cool:

<div class="[--my-var:2rem] lg:[--my-var:4rem]">

Like other arbitrary stuff, you use _ to represent spaces where necessary:

<div class="[margin:2px_4px_5px_1px]">

@adamwathan adamwathan merged commit d261531 into master Nov 22, 2021
@adamwathan adamwathan deleted the arbitrary-properties branch November 22, 2021 17:38
Copy link

techniq commented Nov 22, 2021

@adamwathan This is great, thanks!

Btw, it might be worth providing an example of accessing the theme within an arbitrary property, as this also fulfills my idea for CSS theme color variables:

<div class="[--color:theme(]" />

Copy link
Member Author

Ah yeah that should honestly just work 👍🏻

Copy link

techniq commented Nov 22, 2021

@adamwathan It does, I was just confirming :). Here's an example

Copy link

minischetti commented Dec 15, 2021

Lovely! My team would like to adopt the JIT engine but are currently using a defined style system with Tailwind that we'd prefer to keep restricted under current circumstances. We haven't had a need yet to override. The documentation mentioned that a strict mode may come in the future. Is this still being considered?

"We’ll likely add some form of “strict mode” in the future for power-hungry team leads who don’t trust their colleagues to use this feature responsibly."

As an alternative, perhaps we can do this via linting for now.

Thanks in advance and congrats on the 3.0.0 release!

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

Successfully merging this pull request may close these issues.

None yet

3 participants