Polished is a small JavaScript library of Sass-style functions and mixins for writing styles in JS. It targets CSS-in-JS workflows and keeps a consistent color palette across an app.
Overview
Polished supplies helper functions for authors who write styles as JavaScript objects rather than in a preprocessor. It brings color utilities, typography helpers, and related mixins in a functional style where color functions are curried so you can compose reusable helpers.
Modules are meant to be imported individually rather than pulling in the whole package, which helps bundlers such as webpack and Rollup tree-shake unused code. Documentation lives at polished.js.org, with examples using object spread for style objects.
The package ships TypeScript definitions and first-class Flow support. An optional Babel plugin can compile static function calls at build time to reduce runtime cost. Browser support includes evergreen browsers plus IE11.
Polished works with libraries that accept styles as JS objects, including styled-components, radium, aphrodite, glamor, glamorous, and jss. Compared with Sass, a functional API and curried color helpers are the main design difference.
Key features
- Sass-style helpers for JS styles
- Curried composable color functions
- Per-module imports for tree shaking
- TypeScript and Flow definitions
- Optional Babel compile-time plugin
- Works with major CSS-in-JS libraries
- Documentation site with usage examples
- Supports evergreen browsers and IE11
Use cases
- CSS-in-JS styling with styled-components
- Consistent color palettes in React apps
- Migrating from Sass to inline styles
- Shared typography and layout helpers
- Small bundle-friendly style utilities