Created
January 7, 2022 19:54
-
-
Save hnordt/6070ed7a164e7bf122174460b8ba18f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add to your tailwind.config.js | |
const plugin = require("tailwindcss/plugin") | |
const radixPlugin = plugin(({ addVariant }) => { | |
const dataStates = [ | |
"open", | |
"closed", | |
"active", | |
"inactive", | |
"on", | |
"off", | |
"checked", | |
"unchecked", | |
"indeterminate", | |
"loading", | |
"complete", | |
"hidden", | |
"delayed-open", | |
] | |
dataStates.forEach((state) => { | |
// e.g. state-open:text-slate-500 | |
addVariant(`state-${state}`, `&[data-state="${state}"]`) | |
// e.g. group-state-open:text-slate-500 | |
addVariant( | |
`group-state-${state}`, | |
`:merge(.group)[data-state="${state}"] &` | |
) | |
}) | |
}) | |
module.exports = { | |
...yourConfig, | |
plugins: [ | |
...yourPlugins, | |
radixPlugin | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment