Gathering detailed insights and metrics for react-free-style
Gathering detailed insights and metrics for react-free-style
Gathering detailed insights and metrics for react-free-style
Gathering detailed insights and metrics for react-free-style
Make React components easier and more maintainable by using inline style objects
npm install react-free-style
Typescript
Module System
Node Version
NPM Version
70.3
Supply Chain
99.4
Quality
76.2
Maintenance
100
Vulnerability
100
License
Upgrade dependencies
Updated on Jan 24, 2021
Handle `insertRule` errors
Updated on Jun 07, 2020
Upgrade Free Style
Updated on May 02, 2020
Fix `styled` ref
Updated on Apr 12, 2020
Allow multiple CSS values
Updated on Mar 30, 2020
Recursive Computed CSS
Updated on Mar 27, 2020
TypeScript (88.04%)
JavaScript (11.96%)
Total Downloads
74,643
Last Day
2
Last Week
23
Last Month
298
Last Year
6,352
MIT License
138 Stars
254 Commits
2 Forks
3 Watchers
8 Branches
6 Contributors
Updated on Mar 30, 2025
Minified
Minified + Gzipped
Latest Version
11.1.0
Package Id
react-free-style@11.1.0
Unpacked Size
75.11 kB
Size
13.00 kB
File Count
18
NPM Version
6.14.9
Node Version
15.6.0
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
-86.2%
23
Compared to previous week
Last Month
-41.1%
298
Compared to previous month
Last Year
-35.2%
6,352
Compared to previous year
2
1
24
React Free Style combines Free Style with React.js by managing the style of React components dynamically. Works with server-side rendering, where only styles of rendered components will print.
Check out why you should be doing CSS in JS. This module exposes the API directly to React.js.
Even more improvements with React Free Style
npm install react-free-style --save
1import { styled } from "react-free-style"; 2 3const Button = styled("button", { 4 backgroundColor: "red", 5}); 6 7const App = () => { 8 return <Button css={{ color: "blue" }}>Hello world!</Button>; 9};
1/** @jsx jsx */ 2 3import { jsx } from "react-free-style"; 4 5const App = () => { 6 return ( 7 <button css={{ color: "blue", backgroundColor: "red" }}> 8 Hello world! 9 </button> 10 ); 11};
1import { css, useCss } from "react-free-style"; 2 3// Creates "cached CSS": 4const style = css({ color: "red" }); 5// But you can also write `const style = { color: "red" }`. 6 7const Button = () => { 8 const className = useCss(style); 9 10 return <button className={className}>Hello world!</button>; 11};
This is how the styled
and jsx
work! Knowing how it works can help you when you need to extract the class name for integrating with an existing UI library using className
.
Every CSS method accepts:
css(...)
methodStyle
and returns a valid styleComponents created using styled
expose "cached CSS" on the style
property.
1const LargeButton = styled("button", [ 2 { 3 fontSize: 16, 4 }, 5 Button.style, 6 { 7 marginBottom: 8, 8 }, 9]);
A "computed CSS" function can be used to register and use @keyframes
.
1import { css } from "react-free-style"; 2 3const style = css((Style) => { 4 const animationName = Style.registerStyle({ 5 $global: true, 6 "@keyframes &": styles, 7 }); 8 9 return { animationName }; 10});
The most effective CSS themes I've seen use CSS variables to dynamically change styles.
1// Register this CSS wherever you want the theme to apply, e.g. `:root`. 2const theme = { 3 "--color": "red", 4}; 5 6const Button = styled("button", { 7 color: "var(--color)", 8}); 9 10// Later on you can change the theme. 11const style = css({ 12 "--color": "blue", 13});
Use React.Context
to define a theme and custom components with css
props.
1const ThemeContext = React.createContext({ 2 color: "red", 3}); 4 5const Button = () => { 6 const theme = React.useContext(ThemeContext); 7 8 return <button css={{ color: theme.color }}>Hello world!</button>; 9};
By default, CSS output is discarded (a "no op" useful for testing) because you may have different output requirements depending on the environment.
StyleSheetRenderer
is an efficient CSS renderer for browsers.
1import { StyleSheetRenderer, Context } from "react-free-style"; 2 3// const renderer = new NoopRenderer(); 4const renderer = new StyleSheetRenderer(); 5 6React.render( 7 <Context.Provider value={renderer}> 8 <App /> 9 </Context.Provider>, 10 document.body 11);
MemoryRenderer
collects all styles in-memory for output at a later time.
1import { MemoryRenderer, Context } from "react-free-style"; 2 3// const renderer = new NoopRenderer(); 4const renderer = new MemoryRenderer(); 5 6const content = ReactDOM.renderToString( 7 <Context.Provider value={renderer}> 8 <App /> 9 </Context.Provider>, 10 document.body 11); 12 13const html = ` 14<!doctype html> 15<html> 16 <head> 17 ${renderer.toString()} 18 </head> 19 <body> 20 <div id="content"> 21 ${content} 22 </div> 23 </body> 24</html> 25`;
MIT license
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/15 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
78 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Morestyle-it
Component for writing plaintext CSS in React apps -- isomorphic, scoped, FOUC-free, fully featured, CSS-in-JS
@remixicon/react
Remix Icon is a set of open source neutral style system symbols elaborately crafted for designers and developers. All of the icons are free to use for both personal and commercial.
@lechihuy/gennote-react
A free block-style editor based on Tiptap
react-native-worry-free-style-sheet
省心的React-Native StyleSheet工具方法