Skip to content

Instantly share code, notes, and snippets.

@thelevicole
Created March 30, 2019 17:04
Show Gist options
  • Save thelevicole/21cc96b5778169cb0e23fae49a47e11a to your computer and use it in GitHub Desktop.
Save thelevicole/21cc96b5778169cb0e23fae49a47e11a to your computer and use it in GitHub Desktop.
Access Bootstrap breakpoints in via Javascript
const styles = getComputedStyle( document.body );
/**
* Get the globally set bootstrap breakpoints
*
* @type {object}
*/
const breakpoints = {
xs: parseInt( styles.getPropertyValue( '--breakpoint-xs' ) ),
sm: parseInt( styles.getPropertyValue( '--breakpoint-sm' ) ),
md: parseInt( styles.getPropertyValue( '--breakpoint-md' ) ),
lg: parseInt( styles.getPropertyValue( '--breakpoint-lg' ) ),
xl: parseInt( styles.getPropertyValue( '--breakpoint-xl' ) )
};
@thelevicole
Copy link
Author

Now implemented into its own library. https://github.com/thelevicole/breakpoints.js

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