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
@borderlesslabs/ui
UI components based on React Free Style and Atoms
react-onclickoutside
An onClickOutside wrapper for React components
@react-native/normalize-colors
Color normalization for React Native.
react-native-webview
React Native WebView component for iOS, Android, macOS, and Windows
npm install react-free-style
Upgrade dependencies
Published on 24 Jan 2021
Handle `insertRule` errors
Published on 07 Jun 2020
Upgrade Free Style
Published on 02 May 2020
Fix `styled` ref
Published on 12 Apr 2020
Allow multiple CSS values
Published on 30 Mar 2020
Recursive Computed CSS
Published on 27 Mar 2020
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
139 Stars
254 Commits
2 Forks
4 Watching
1 Branches
6 Contributors
Updated on 06 Aug 2024
Minified
Minified + Gzipped
TypeScript (88.04%)
JavaScript (11.96%)
Cumulative downloads
Total Downloads
Last day
150%
20
Compared to previous day
Last week
-40%
51
Compared to previous week
Last month
-30.2%
379
Compared to previous month
Last year
-41.2%
7,279
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
69 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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 More