A less than 1KB css-in-js solution
open sourceMITself-hostablefree
goober is a CSS-in-JS library of about 1KB with the familiar styled, css, keyframes and global styles APIs, written as a smaller alternative to styled-components and Emotion. It is framework agnostic: you call setup with React's createElement or Preact's h, and it can render styles into any DOM target, which helps with web components. It supports theming, a prefixer, server-side rendering through extractCss, TypeScript types and Content Security Policy nonces for its style tag. Babel, Next.js, Gatsby and Preact CLI integrations are available.
Problems it solves
- styled-components adds too many kilobytes to my small widget
- I want the styled API in Preact without pulling in a big library
- scope styles inside a web component or a specific DOM node
- my inline styles get blocked by a strict content security policy
- server-render critical CSS for my components
- theme colours and sizes across components with a tiny CSS-in-JS library
- write component styles in JavaScript for an embeddable script where every byte counts
- add vendor prefixes to CSS generated at runtime
- a CSS-in-JS library that works with React and Preact alike
Features
- styled, css, keyframes and createGlobalStyles APIs
- about 1KB
- framework agnostic (React, Preact)
- render into any DOM target
- theming
- shouldForwardProp
- server-side rendering with extractCss
- prefixer (goober/prefixer)
- TypeScript types
- CSP nonces via window.nonce
View 2 more
- Babel plugin and macro
- Next.js, Gatsby and Preact CLI integrations
Capabilities
| Takes plugins | plan not known |
|---|
Alternatives
The same job
These do what goober does.
- styled-components Fast, expressive styling for React. Server components, client components, streaming SSR, React Native, all one API.
- Emotion CSS-in-JS library designed for high performance style composition
