styled-components
linaria
Our great sponsors
- Appwrite - The open-source backend cloud platform
- Amplication - open-source Node.js backend code generator
- SurveyJS - A Non-Cloud Alternative to Google Forms that has it all.
- Sonar - Write Clean JavaScript Code. Always.
- InfluxDB - Collect and Analyze Billions of Data Points in Real Time
- Mergify - Updating dependencies is time-consuming.
styled-components | linaria | |
---|---|---|
213 | 45 | |
39,486 | 10,799 | |
0.5% | 0.8% | |
9.0 | 8.2 | |
6 days ago | 9 days ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
styled-components
-
Media Queries and Responsive Design
You can use Media Queries in Styled-Components similar to how you would use them in CSS, other than the fact that you can define custom screen sizes in your theme and access them inside your Media Queries:
-
CSS lobotomized owl selector: A modern guide
The above is still a more "traditional" way to use CSS. Let's look at a CSS-in-JS example that makes use of styled-components:
-
An Overview of 25+ UI Component Libraries in 2023
As such, a new breed of solution was born — CSS in JS. Mostly prevalent in the React ecosystem, libraries such as Styled Components and Emotion allowed scoping styles to components and in so, got rid of the cascade problem.
-
MDN Playground
Not trying to start a flame war but what can you do with these that can't be accomplished with React and e.g. https://styled-components.com ?
-
5 DRY Principles To Follow In React
Finally, I came across styled-components which is an awesome library to re-use styles for components. For me, it helps to create much more readable components and no more className inside my code!
-
20 Essential Parts Of Any Large Scale React App
styled-components
-
6 Regrets I Have As a React Developer
Testing: react-testing-library, jest Styling: styled-components Form: react-hook-form Tools: EsLint and Prettier
-
Is there any way to apply different CSS files to the same component?
I’ve had good experiences with the styled-components library
-
The app router is not production-ready yet
Styled components issue for reference: https://github.com/styled-components/styled-components/issues/3856
-
I created a Zero-Runtime CSS-in-JS Library Compatible with Next.js App Router and RSC
Over my years of working with React, I’ve loved using CSS-in-JS libraries like Emotion and Styled-components. However, their inherent performance overhead from injecting CSS at runtime and their incompatibility with the latest Next.js features such as App Router and React Server Components (RSC) have always been a nagging issue for me.
linaria
-
An Overview of 25+ UI Component Libraries in 2023
KumaUI : Another relatively new contender, Kuma uses zero runtime CSS-in-JS to create headless UI components which allows a lot of flexibility. It was heavily inspired by other zero runtime CSS-in-JS solutions such as PandaCSS, Vanilla Extract, and Linaria, as well as by Styled System, ChakraUI, and Native Base. ### Vue
-
Why Tailwind CSS Won
I like Linaria [0] because your IDE typechecks your styles and gives you autocomplete/intellisense when typing styles. With Tailwind you have to look everything up in docs because it's all strings, not importable constants. Leads to a lot of bugs from typos that aren't a thing with type checked styles.
-
I've decided to go back to using the Pages Router for now (long post)
And if you're wondering why I'm not using something like Linaria or some other runtime-less CSS-in-JS tool, it's simply because I don't want to have to spend my time setting things up and working around stuff and all that jazz. I just want something that works, and I've already got a personal scaffold for getting SC to work out of the box with Next, so, right now, it's either that or sticking to CSS/SCSS/SASS. For me, that is. I know it's such a small thing, but, honestly, one less headache for me is 2 steps forward.
-
What's the best option these days for CSS in JS?
https://github.com/vanilla-extract-css/vanilla-extract and https://github.com/callstack/linaria
-
Why is tailwind so hyped?
tags inside SFCs are typically injected as native
tags during development to support hot updates. For production they can be extracted and merged into a single CSS file.
There are also 3rd party CSS libs that do the same thing such as linaria, vanilla-extract, and compiled CSS. Which can be used in the event you're stuck with something that doesn't have baked in support via SFC formats (looking at you React).
These are my preferred ways of handing it.
- Tailwind
Option 2 is tailwind, which works backwards.
That is, instead of the above with extraction where you write the styles, and the framework or libs extract them and replace them with class names, it's the other way around.
You're writing class names first (which are essentially aggregated CSS property-values) which then generate and/or reference styles.
It has the advantage of being easy to write (assuming you've got editor LSP, linting, etc), but as you've discovered, it's difficult to read / can get really messy really fast.
As far as all the other claims on the Tailwind site, it's all marketing, at least 80% bullshit.
- Individual css for every component?
-
Fixing Class Composition in Tailwind CSS
After exploring all the above alternatives (and more), I’ve decided to implement my own, custom solution. For that, I’ve turned to Linaria - a true zero-runtime CSS-in-JS library.
-
Hey friendos, need some help choosing a "framework" with some specific requirements in mind
Your choice of CSS lib. Bootstrap can still be a valid choice, tho you may want to check the docs of whatever SSR / SSG framework you end up using as they may have better (or worse support). For example if you wanted to do CSS-in-JS (Next) i'd consider Linaria, vanilla-extract, or compiled.
-
CSS vs CSS-in-JS performance
I never tested myself tbh, but that’s a surprising result as on production you only have plain old CSS https://github.com/callstack/linaria/blob/master/docs/HOW_IT_WORKS.md The styled syntax should be extracted the same way as the css helpers. I’m not sure if under some condition the styles get inlined? Perhaps on dev env?
What are some alternatives?
styled-jsx - Full CSS support for JSX without compromises
chakra-ui - ⚡️ Simple, Modular & Accessible UI Components for your React Applications
emotion - 👩🎤 CSS-in-JS library designed for high performance style composition
styletron - :zap: Toolkit for component-oriented styling
JSS - JSS is an authoring tool for CSS which uses JavaScript as a host language.
PostCSS - Transforming styles with JS plugins
material-ui - MUI Core: Ready-to-use foundational React components, free forever. It includes Material UI, which implements Google's Material Design.
Aphrodite - Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation
react-bootstrap - Bootstrap components built with React
Tailwind CSS - A utility-first CSS framework for rapid UI development.
vanilla-extract - Zero-runtime Stylesheets-in-TypeScript