Download latest (or Prefixed - great with Bootstrap) | Get Starded | Contribute | Documentation |
Why LESS Hat? In August 2012, while we were developing and extending CSS Hat for LESS we needed universal mixins. Unfortunately, none of available were good enough that would satisfy our needs and that’s why we created new custom ones on our own, which have become the most popular mixin library for the whole LESS CSS.
After a year, there is a new, completely rewritten 2.0 version that brings 86 great mixins, robust workflow for editing, testing and creating new mixins.
Meet the best mixins library in the world. Thanks to the LESS Hat 2.0 is LESS CSS finally usable.
If you would like to use CSS Hat for working with LESS Hat and you still don't have one, we have a suprise for you at lesshat.com - Check it out!
- Configuration – You can turn off/on browser prefixes according to your needs.
- No restrictions – If it's possible in CSS, it must be possible to be done with a mixin. Unlimited number of anything, shadows, gradients, gradient swatches.
- Standard naming convention – In LESS Hat, mixins have names like all CSS3 properties. No
.rounded
or.shadow
. It's stupid. - Cross-browser – LESS Hat takes care of exporting CSS for all available browsers.
- Bootstrap friendly – You can now use prefixed LESS Hat version and gaily work with Bootstrap. Yeah it's that easy.
- Keyframes – Although it's tricky as hell, but yeah LESS Hat has mixin for
.keyframes
- Blank state ready – If you call mixin without any arguments, LESS Hat does not pollute your CSS with empty properties. Instead LESS Hat generates nothing.
- Workflow – No more one line editing! We created developer friendly worklow for editing and creating mixins. You can test mixins with MOCHA, generate new mixin with GRUNT. Find out more about the workflow in contribution section.
The structure of this repo is:
- build folder – there are ready-to-use lesshat.less or lesshat-prefixed.less mixins
- mixins folder – developer version of mixins (more about that in contribution section)
- .gitignore – is a list of files that git will ignore. I know you know that, but it's convention.
- .travis.yml – Configuration file for Travis CI. Travis CI is a hosted continuous integration service for the open source community.
- Gruntfle.js – task runner. If you don't want to use lesshat-devstack ignore it.
- LICENCE – self-explanatory
- README-template.md – If you want to edit readme, edit it in this file. README.md is generated.
- README.md – please don't edit this file. Either edit README-template.md or documentation inside mixins/ folder.
- Bower – is like NPM for frontend. NPM is like Gems for JavaScript. I could go on forever…
- package.json – contains meta data for NPM.
-
Global prefix configuration:
@webkit: true; @moz: true; @opera: true; @ms: true; @w3c: true;
If you for example don't want to generate prefixes for opera, just turn it to false.
-
Typical LESS Hat mixin:
.supermixin(...) { @webkit_local: true; @w3c_local: true; @process: ~`(function(){})()`; .result (@arguments, @signal, @boolean, @local_boolean) when (@boolean = true) and (@local_boolean = true) { .inception (@signal, @arguments) when (@signal = 1) and not (@process = 08121991) { -webkit-border-radius: @process; } .inception (@signal, @arguments) when (@signal = 1) and (@process = 08121991) {} .inception (@signal, @arguments) when (@signal = 3) and not (@process = 08121991) { border-radius: @process; } .inception (@signal, @arguments) when (@signal = 3) and (@process = 08121991) {} .inception(@signal, @arguments); } .result (@arguments, @signal, @boolean, @local_boolean) when not (@boolean = true), not (@local_boolean = true) {} .result(@arguments, 1, @webkit, @webkit_local); .result(@arguments, 3, @w3c, @w3c_local); }
At the top, there are a local prefix configurations. So you can turn off/on browser for one specific mixin. This is quite useful.
In @process variable is all magic. Please don't edit javascrpt directly in .less file. Instead use lesshat-devstack.
If you call mixin without arguments, some mixins return CSS default value for specific property, but some mixins return magic number 08121991 (Yeah, it's like Lost, TV series, but numbers are different) and because of that LESS CSS generates nothing.
Why 08121991 and not just 0 (zero)?
Some CSS properties have zero as default value. So we need more difficult number. -
Use (almost) every property without interpolation!
Correct mixin calling:
.background-image(linear-gradient(to bottom, #fb83fa 0%,#e93cec 100%))
Incorrect calling:
.background-image(~'linear-gradient(to bottom, #fb83fa 0%,#e93cec 100%)')
Unfortunately, there are exceptions:
.keyframes(~''); .calc(~''); .selection(~''); // in some cases you have to interpolate border-radius or LESS CSS begins to play on calculator .border-radius(~'20px / 40px');
- Download this repo.
- NPM install.
- Now you have LESS Hat devstack (see documentation.)
- If you create new mixin, use grunt generate command!
- If it's possible (almost always) test the coverage for new mixins, and never break existing tests.
- Commits should represent one logical change each. If a mixin goes through multiple iterations, squash your commits down to one.
- Finally, commit some code and open a pull request.
- align-content
flexbox
- align-items
flexbox
- align-self
flexbox
- animation
- animation-delay
- animation-direction
- animation-duration
- animation-fill-mode
- animation-iteration-count
- animation-name
- animation-play-state
- animation-timing-function
- appearance
- backface-visibility
- background-clip
- background-image
- background-origin
- background-size
- blur
filter
- border-bottom-left-radius
- border-bottom-right-radius
- border-image
- border-radius
- border-top-left-radius
- border-top-right-radius
- box-shadow
- box-sizing
- brightness
filter
- calc
- column-count
- column-gap
- column-rule
- column-width
- columns
- contrast
filter
- display
flexbox
- drop-shadow
filter
- filter
- flex
flexbox
- flex-basis
flexbox
- flex-direction
flexbox
- flex-grow
flexbox
- flex-shrink
flexbox
- flex-wrap
flexbox
- font-face
- grayscale
filter
- hue-rotate
filter
- invert
filter
- justify-content
flexbox
- keyframes
- opacity
- order
- perspective
- perspective-origin
- placeholder
- rotate
transform
- rotate3d
transform
- rotateX
transform
- rotateY
transform
- rotateZ
transform
- saturate
filter
- scale
transform
- scale3d
transform
- scaleX
transform
- scaleY
transform
- scaleZ
transform
- selection
- sepia
filter
- size
width, height
- skew
transform
- skewX
transform
- skewY
transform
- transform
- transform-origin
- transform-style
- transition
- transition-delay
- transition-duration
- transition-property
- transition-timing-function
- translate
transform
- translate3d
transform
- translateX
transform
- translateY
transform
- translateZ
transform
- user-select
{{ documentation }}
- Jan Kuca (help us with lesshat-devstack)
- MOZILLA DEVELOPER NETWORK (almost all summary are from MDN)
- CSS-Tricks (their CSS almanac is great resource)
- Angular UI router (example of good github profile)
- Marek Hrabe (for coding lesshat.com)
- Jan Vu Nam (for design lesshat.com and LESS Hat book icon)