Prefixed: Handles browser prefixing out of the box.
Ultralight: Generated on the fly—no stylesheets.
Use short-hand utilities within JS to generate your styles in the DOM. For a CSS-only solution, check out gr8. Prepped for use with Browserify, pairs nicely with choo and yo-yo. Shoutout understyle, f(css), etc…
gr8r('We construct and keep on constructing...','c12 m2')
// <div class="cxs-3919501705">We construct...
gr8r(yo`<header>yet intuition is still a good thing.</header>`,'c12 m2')
// <header class="cxs-3919501705">yet intuition…
Arguments
Methods can contain variable arguments such as c6 and p2, or predefined rules like ttu. It’s also possible to pass a string as an argument using : as a delimiter. For example, you could add a custom method called bg and use it with the shorthand bg:black.
Units
It’s possibible to set a custom unit when declaring the value of a method. Fallsback to options unit.
gr8r('When I haven’t any blue…','p20px')
gr8r('... I use red.','p2')
Breakpoints
Methods can be redeclared for each breakpoint. Additionally, use an integer as a key to get ultra-specific.
gr8r('Put this there.','p2',{
xl:'p6',
lg:'p4',
600:'p3.5',
md:'p3',
sm:'p2'
})
Options
Several options are configurable by calling setOptions.
constgr8r=require('gr8r')
gr8r.setOptions({
breakpoints:{
xl:'1439px',
lg:'1260px',
md:'1023px',
sm:'767px'
},
// Min or max width
max:true,
// Grid
cols:12,
// Default unit when none is passed
unit:'rem'
})
Custom Methods
It’s possible to extend gr8r by creating your own methods. Ensure you’re returning an object which contains the appropriately formatted CSS styles. Prefixing is handled for you.
constgr8r=require('gr8r')
gr8r.addMethod({
match:'omg',
value:({ omg })=>{
constcolor='gold'
return{ border:'20px solid '+ color }
}
}
gr8r.e('It works!','p3 c6 omg',{ md:'p1'})
Methods
Background
Utility
Value
Attribute
Returns
bgsc
background-size
cover
bgsct
background-size
contain
bgpc
background-position
center
bgpt
background-position
top
bgpr
background-position
right
bgpb
background-position
bottom
bgpl
background-position
left
bgrn
background-repeat
no-repeat
bgrx
background-repeat
repeat-x
bgry
background-repeat
repeat-y
bgn
background
none
Shortcuts
Utility
Value
Returns
bgc
bsc bgpc bgrn
bgct
bsct bgpc bgrn
Column
Columns are calculated by comparing the passed value against the cols option. By default there are 12 columns, so passing 6 will return a width of 50%. Additionally, you can offset a column (co) in a similar way, which will push the column to the right by returning margin-left.
Utility
Value
Attribute
Returns
c
int/float
width
(value/cols)%
co
int/float
margin-left
(value/cols)%
Dev
This is useful for seeing the underlying structure of an element for debugging purposes.