Skip to content

Instantly share code, notes, and snippets.

@farishan
Last active October 5, 2021 12:38
Show Gist options
  • Save farishan/c966c894596e03e575ea3e84749b972b to your computer and use it in GitHub Desktop.
Save farishan/c966c894596e03e575ea3e84749b972b to your computer and use it in GitHub Desktop.
farishan tailwind custom breakpoints | farishan tailwind custom container plugin
/**
* Custom Breakpoints
*/
const screens = {
sm: '375px',
md: '768px',
mdp: '900px',
lg: '1024px',
xl: '1280px',
'2xl': '1440px',
'3xl': '1900px',
'4xl': '2500px'
};
/**
* Custom Container Plugin - modifies Tailwind’s default container.
* Deps: Custom Breakpoints
*/
const containerPlugin = ({ addComponents }) => {
const containerBase = {
maxWidth: '100%',
marginLeft: 'auto',
marginRight: 'auto',
paddingLeft: '16px',
paddingRight: '16px',
'@screen md': {
paddingLeft: '30px',
paddingRight: '30px'
},
'@screen xl': {
paddingLeft: '80px',
paddingRight: '80px'
},
'@screen 2xl': {
paddingLeft: 0,
paddingRight: 0
}
};
addComponents({
'.container': {
...containerBase,
'@screen xl': {
maxWidth: screens['xl']
}
},
'.container-fluid': {
...containerBase,
'@screen lg': {
paddingLeft: '45px',
paddingRight: '45px'
}
}
});
};
// usage:
// plugins: [containerPlugin]
@farishan
Copy link
Author

farishan commented Oct 5, 2021

farishan tailwind custom breakpoints | farishan tailwind custom container plugin

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