Gathering detailed insights and metrics for fela
Gathering detailed insights and metrics for fela
Gathering detailed insights and metrics for fela
Gathering detailed insights and metrics for fela
npm install fela
Typescript
Module System
Node Version
NPM Version
JavaScript (71.17%)
MDX (15.06%)
HTML (13.58%)
Reason (0.16%)
CSS (0.03%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2,283 Stars
2,249 Commits
183 Forks
20 Watchers
4 Branches
128 Contributors
Updated on Jul 16, 2025
Latest Version
12.2.1
Package Id
fela@12.2.1
Unpacked Size
93.60 kB
Size
21.55 kB
File Count
49
NPM Version
lerna/4.0.0/node@v16.17.1+arm64 (darwin)
Node Version
16.17.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
5
Fela is a small, high-performant and framework-agnostic toolbelt to handle state-driven styling in JavaScript.
It is dynamic by design and renders your styles depending on your application state.
It generates atomic CSS and supports all common CSS features such as media queries, pseudo classes, keyframes and font-faces. Fela ships with a powerful plugin API adding e.g. vendor prefixing or fallback value support.
Fela can be used with React or with any other view library. It even supports React Native.
Support Robin Weser's work on Fela and its ecosystem directly via GitHub Sponsors.
Fela's core principle is to consider style as a function of state.
The whole API and all plugins and bindings are built on that idea.
It is reactive and auto-updates once registered to the DOM.
The following example illustrates the key parts of Fela though it only shows the very basics.
1import { createRenderer } from 'fela' 2 3// a simple style rule is a pure function of state 4// that returns an object of style declarations 5const rule = (state) => ({ 6 textAlign: 'center', 7 padding: '5px 10px', 8 // directly use the state to compute style values 9 fontSize: state.fontSize + 'pt', 10 borderRadius: 5, 11 // deeply nest media queries and pseudo classes 12 ':hover': { 13 fontSize: state.fontSize + 2 + 'pt', 14 boxShadow: '0 0 2px rgb(70, 70, 70)', 15 }, 16}) 17 18const renderer = createRenderer() 19 20// fela generates atomic CSS classes in order to achieve 21// maximal style reuse and minimal CSS output 22const className = renderer.renderRule(rule, { 23 fontSize: 14, 24}) // => a b c d e f
The generated CSS output would look like this:
1.a { text-align: center } 2.b { padding: 5px 10px } 3.c { font-size: 14pt } 4.d { border-radius: 5px } 5.e:hover { font-size: 16pt } 6.f:hover { box-shadow: 0 0 2px rgb(70, 70, 70) }
If you're using Fela, you're most likely also using React.
Using the React bindings, you get powerful APIs to create primitive components.
Read: Usage with React for a full guide.
1import * as React from 'react' 2import { useFela } from 'react-fela' 3 4const rule = ({ fontSize }) => ({ 5 textAlign: 'center', 6 padding: '5px 10px', 7 // directly use the props to compute style values 8 fontSize: fontSize + 'pt', 9 borderRadius: 5, 10 ':hover': { 11 fontSize: fontSize + 2 + 'pt', 12 boxShadow: '0 0 2px rgb(70, 70, 70)', 13 }, 14}) 15 16function Button({ fontSize, children }) { 17 const { css } = useFela({ fontSize }) 18 19 return <button className={css(rule)}>{children}</button> 20}
Check this example on CodeSandbox
If you are coming from CSS and want to learn JavaScript Styling with Fela, there is a full-feature fela-workshop which demonstrates typical Fela use cases. It teaches all important parts, step by step with simple examples. If you already know other CSS in JS solutions and are just switching to Fela, you might not need to do the whole workshop, but it still provides useful information to get started quickly.
There are tons of useful packages maintained within this repository including plugins, enhancers, bindings and tools that can be used together with Fela. Check the Ecosystem documentation for a quick overview.
Apart from all the packages managed within this repository, there are many community third-party projects that are worth mentioning:
connect
with auto-bound stylesGot a question? Come and join us on Spectrum!
We'd love to help out. We also highly appreciate any feedback.
Don't want to miss any update? Follow us on Twitter.
Your company is using Fela, but is not listed yet? Add your company / organisation
This project exists thanks to all the people who contribute.
We highly appreciate any contribution.
For more information follow the contribution guide.
Also, please read our code of conduct.
Fela is licensed under the MIT License.
Documentation is licensed under Creative Commons License.
Created with ♥ by @robinweser and all the great contributors.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 15/30 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
115 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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