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

Implement the supports variant #9453

Merged
merged 3 commits into from Oct 4, 2022
Merged

Implement the supports variant #9453

merged 3 commits into from Oct 4, 2022

Conversation

RobinMalfait
Copy link
Contributor

@RobinMalfait RobinMalfait commented Sep 30, 2022

This PR adds a new supports variant.

It allows you to check if a certain css property / value is supported or not so that you can apply certain utilities or not.

This variant doesn't ship with any named variants, but you can use arbitrary variants which gives you the full flexibility of this variant plugin.

E.g.:

<div class="supports-[display:grid]:grid"></div>

Which results in the following css:

@supports (display: grid) {
  /* ... */
}

If you require spaces in your supports check, then you can use the _ similar to how we handle that in arbitrary values already.

<div class="supports-[transform-origin:5%_5%]:grid"></div>

Which results in the following css:

@supports (transform-origin: 5% 5%) {
  /* ... */
}

If you are just interested in checking wether the propery is supported regardless of the value, then you can just provide the property name and we will fill in a value for you:

<div class="supports-[container-type]:grid"></div>

Which results in the following css:

@supports (container-type: var(--tw)) {
  /* ... */
}

We also read from your config file if you want named supports variants if there is a check you are repeating all over the place.

module.exports = {
  theme: {
    // ...
    supports: {
      grid: 'display: grid'
    }
  }
}
<div class="supports-grid:grid"></div>

@RobinMalfait RobinMalfait force-pushed the feat/supports-variant branch 7 times, most recently from 941389f to c632570 Compare October 4, 2022 15:49
@RobinMalfait RobinMalfait merged commit 7677c59 into master Oct 4, 2022
@RobinMalfait RobinMalfait deleted the feat/supports-variant branch October 4, 2022 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant