Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankdejonge/8e4ce4715cff96b2a61355f41de474f4 to your computer and use it in GitHub Desktop.
Save frankdejonge/8e4ce4715cff96b2a61355f41de474f4 to your computer and use it in GitHub Desktop.
Tailwind plugin to add screen variants up until a breakpoint
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