Created
July 16, 2022 18:15
-
-
Save frankdejonge/8e4ce4715cff96b2a61355f41de474f4 to your computer and use it in GitHub Desktop.
Tailwind plugin to add screen variants up until a breakpoint
This file contains hidden or 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
const plugin = require('tailwindcss/plugin'); | |
let untilBreakpoint = plugin(({ addVariant, config }) => { | |
let screens = config('theme.screens'); | |
for (let screen in screens) { | |
let def = screens[screen]; | |
if (typeof def === 'string') { | |
addVariant(`-${screen}`, `@media (max-width: calc(${def} - 1px))`); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment