Please consider donating to this project's author, EGOIST, to show your ❤️ and support.
Install
npm i style-module
Use UMD bundle from CDN
Use ESM bundle from CDN
Usage
Check out the live demo on CodePan.
const buttonStyles = const styles = // Generated class namesconsole//=> main: 'sm_2' button: 'sm_0 sm_3'
Composes
Composes (i.e. inherits) all styles from an existing class name which is usually generated by css
or styleModule
function:
const defaultButton = const primaryButton =
Notes:
composes
currently only works at the top level.- It's possible to compose multiple classes with
composes: `${classNameA} ${classNameB}`
API
css
Generate class name for a style record:
const className = className //=> sm_0
styleModule
Generate class names for multiple style records (a module):
const styles = stylesbutton //=> .sm_0
styleModule
is just a short-hand for generating multiple class names at once, internally it calls css
function too.
TODO
- Atomic CSS
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
style-module © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).
Website · GitHub @EGOIST · Twitter @_egoistlily