Skip to content

Instantly share code, notes, and snippets.

@patrikengborg
Last active February 4, 2022 20:26
Show Gist options
  • Save patrikengborg/0d78ffce3cea7e8cbb4c255f56244496 to your computer and use it in GitHub Desktop.
Save patrikengborg/0d78ffce3cea7e8cbb4c255f56244496 to your computer and use it in GitHub Desktop.
Function for Tailwind to add a custom variant plugin for RTL sites.
function ({ addVariant }) {
addVariant('rtl', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `[dir="rtl"] .rtl${separator}${className}`
})
})
}
@HamedFathi
Copy link

You should change it to

return `[dir="rtl"] .rtl\\${separator}${className}`

You need \ before ${separator}.

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