Need help with glamor?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

threepointone
3.6K Stars 226 Forks MIT License 749 Commits 76 Opened issues

Description

inline css for react et al

Services available

!
?

Need anything else?

Contributors list

# 3,675
JavaScr...
dropzon...
React
reactjs
532 commits
# 14,355
Common ...
prettif...
coffees...
beautif...
14 commits
# 197,808
CSS
HTML
content...
React
10 commits
# 11,532
chip-8
Emacs
Angular
YAML
6 commits
# 65,344
minific...
Babel
React
css-in-...
5 commits
# 29,488
PHP
node
Electro...
alfred
4 commits
# 201,933
React
css-in-...
CSS
Shell
3 commits
# 1,234
JavaScr...
Babel
package...
reactjs
3 commits
# 261
TypeScr...
React
gatsby
netlify
3 commits
# 77,080
npm
nodemon
node
test-fr...
2 commits
# 290,530
stylus
Sass
PHP
2 commits
# 64,628
CSS
reactjs
flux
Redux
2 commits
# 211
JavaScr...
TypeScr...
Storybo...
vercel
2 commits
# 3,500
React
Markdow...
mdx
unified
2 commits
# 17,004
React
Shell
node
TypeScr...
1 commit
# 779
JavaScr...
Rails
TypeScr...
tesla
1 commit
# 6,143
TypeScr...
mocking...
test-fr...
Babel
1 commit
# 514,140
HTML
JavaScr...
1 commit
# 2,217
HTML
CSS
Git
Zsh
1 commit
# 338,425
JavaScr...
Webpack
uglify
minify
1 commit

glamor

Join the chat at https://gitter.im/glamor-css/Lobby

build status

css in your javascript

npm install glamor --save

usage ```jsx import { css } from 'glamor'

// make css rules let rule = css({ color: 'red', ':hover': { color: 'pink' }, '@media(min-width: 300px)': { color: 'green', ':hover': { color: 'yellow' } } })

// add as data attributes

zomg

// or as classes

zomg

// merge rules for great justice let mono = css({ fontFamily: 'monospace' })

let bolder = css({ fontWeight: 'bolder' })

bold code!
motivation
---

This expands on ideas from @vjeux's 2014 css-in-js talk. We introduce an api to annotate arbitrary dom nodes with style definitions ("rules") for, um, the greater good.

features

  • fast / efficient, with a fluent api
  • framework independent
  • adds vendor prefixes / fallback values
  • supports all the pseudo :classes/::elements
  • @media queries
  • @supports statements
  • @font-face / @keyframes
  • escape hatches for parent / child / contextual selectors
  • dev helper to simulate pseudo classes like :hover, etc
  • server side / static rendering
  • tests / coverage
  • experimental - write real css, with syntax highlighting and linting

(thanks to BrowserStack for providing the infrastructure that allows us to run our build in real browsers.)

docs

extras

speedy mode

there are two methods by which the library adds styles to the document -

  • by appending css 'rules' to a browser backed stylesheet. This is really fast, but has the disadvantage of making the styles uneditable in the devtools sidebar.
  • by appending text nodes to a style tag. This is fairly slow, but doesn't have the editing drawback.

as a compromise, we enable the former 'speedy' mode NODE_ENV=production, and disable it otherwise. You can manually toggle this with the speedy() function.

characteristics

while glamor shares most common attributes of other inline style / css-in-js systems, here are some key differences -

  • uses 'real' stylesheets, so you can use all css features.
  • rules can be used as data-attributes or classNames.
  • simulate pseudo-classes with the simulate helper. very useful, especially when combined when hot-loading and/or editing directly in devtools.
  • really fast, by way of deduping rules, and using insertRule in production.

todo

profit, profit

I get it

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.