9 CSS in JS Libraries You Should Know in 2018

2023-12-15 12:59
文章标签 css js frontend 2018 libraries know

本文主要是介绍9 CSS in JS Libraries You Should Know in 2018,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

转自:https://blog.bitsrc.io/9-css-in-js-libraries-you-should-know-in-2018-25afb4025b9b

实际上  wix 的 stylable 也不错,网上也有相关的比较,以及有优缺点说明

Some of the best CSS in Javascript libraries to use in your app.

When building Bit, turning components into building blocks which can be shared, used and developed anywhere, we had to get deeply familiarized with the various ways people choose to style components in the ecosystem.

Bit - Share and build with code components
Bit helps you share, discover and use code components between projects and applications to build new features and…bitsrc.io

One particularly interesting concept is using JS in CSS to abstract CSS to the component level itself, using JavaScript to describe styles in a declarative and maintainable way. So, we’ve listed some useful projects to get started.

You can also read this recommended discussion to help you make a good decision, and here’s a very cool comparison of projects. Let’s dive in.

1. Styled components

An idea born in an Australian Whisky bar turned into an 18K stars project, widely adopted in the community. Styled-components makes it easier to use CSS in React components, by defining styled-components with encapsulated styles without CSS classes as a mediator layer.

Styled-components are created by defining components using the ES6 template literal notation. CSS properties can be added to the component as needed, just like you would normally do using CSS. When the JS is parsed, styled-components will generate unique class names, and inject the CSS into the DOM. You can learn more in this great talk by Max Stoiber.

Tip: Styled-components can also be combined with Bit, to share them between apps and develop in a visual playground. Take a look.

styled-components/styled-components
styled-components - Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps…github.com
  • Also check out: Stylable by Wix-Eng which is still in development.

2. Radium

At 6.5K stars and created by FormidableLabs, Radium is defined as “A toolchain for React component styling”. It’s set of tools to manage inline styles with React without CSS. Radium offers a standard interface and abstractions for dealing with CSS features that inline styles don’t easily accommodate

Radium lets you bundle up styles with your React components, coupling javascript, html, and styling together. It also provides props-based rendering, allowing you to style your components based on the state of your app.

FormidableLabs/radium
radium - A toolchain for React component styling.github.com

3. Aphrodite


Aphrodite is a framework-agnostic CSS-in-JS library with support for server-side rendering, browser prefixing, and minimum CSS generation. Aphrodite transforms everything into classes and uses the class attribute.

At 4K stars, this project works with or without React and provides features such as injecting styled into the Dom, auto prefixes styles and more, all at a relatively small size of 20k and a handful of dependancies. Here’s a useful Aphrodite vs. Radium rundown.

Khan/aphrodite
aphrodite - Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS…github.com

4. Emotion

At 4.2K stars Emotion is a performant and flexible CSS-in-JS library which allows you to style apps with string or object styles. It has predictable composition to avoid specificity issues with CSS. Based on the glam library and its philosophy the idea is to retain runtime performance when writing CSS by parsing styles with babel and PostCSS. The core runtime is 2.3kb and with React support, 4kb. Emotion isn’t limited to React.

emotion-js/emotion
emotion - style as a function of stategithub.com

5. Glamorous

Note: the project is no longer actively maintained! still cool though :)

At 3.6K stars PayPal’s Glamorous is oriented for building “maintainable CSS with React” inspired by styled-components and jsxtyle. Kent C. Doddsdefine the project as “React component styling solved with an elegant (inspired) API, small footprint (<5kb gzipped), and great performance (via glamor)”. It has a very similar API to styled-components and uses similar tools under the hood.

paypal/glamorous
glamorous - ? Maintainable CSS with Reactgithub.com

6. Glamor

Inspired by ideas from this great talk, Glamor is small and effective. It lets you write inline CSS in your components using the same Object CSS syntax React supports for the style prop. It’s fast and efficient, framework independent, serverside / static rendering and adds vendor prefixes / fallback values. Here’s a short API docs intro, a comparison of CSS techniques in Glamor and a useful tutorial of Glamor with Gatsby.

threepointone/glamor
glamor - inline css for react et algithub.com
  • Also check out: Glam (still under work)

7. Fela

<FelaComponent
style={{
backgroundColor: 'blue',
color: 'red'
}}
render={({ className, theme }) => (
<div className={className}>I am red on blue.</div>
)}
/>

Fela is a project built for State-Driven Styling in JavaScript, emphasizing 3 things: Make styling dynamic by default, bring framework-agnostic (Bindings for React), and being performant. It’s dynamic by design and renders 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. It can be used with any view library, including React native. You can read more about V6 features here.

rofrischmann/fela
fela - State-Driven Styling in JavaScriptgithub.com

8. Styletron

At 2500 stars Styletron is a “toolkit for component-oriented styling”. Styletron supports stateless, single-element styled components as base styling primitive with prop interfaces for conditional/dynamic styling, and a composition of styles via (typed) JavaScript objects without extra tooling (e.g. Webpack loaders, Babel plugins, etc.). It’s also un-opinionated about the shape of style objects. You can learn more at this interesting HN thread.

rtsao/styletron
styletron - :zap: Toolkit for component-oriented stylinggithub.com

9. JSS

JSS is an abstraction over CSS which uses JavaScript to describe styles in a declarative and maintainable way. It is a high performance JS to CSS compiler which works at runtime and server-side. This core library is low level and framework agnostic, and is about 6KB (minified and gzipped). It can also be extended via plugins API. Here’s a nice tutorial for converting SCSS (Sass). Also check out React-JSS, a JSS integration for React.

cssinjs/jss
jss - JSS is an authoring tool for CSS which uses JavaScript as a host language.github.com

Honorable mentions

gajus/react-css-modules
react-css-modules - Seamless mapping of class names to CSS modules inside of React components.github.com
martinandert/babel-plugin-css-in-js
babel-plugin-css-in-js — A plugin for Babel v6 which transforms inline styles defined in JavaScript modules into class…github.com
callstack/linaria
linaria - Zero-runtime CSS in JS librarygithub.com
typestyle/typestyle
typestyle - Making CSS Typesafe ?github.com
streamich/freestyler
freestyler - 5th generation CSS-in-JS librarygithub.com
airbnb/react-with-styles
react-with-styles - Use CSS-in-JavaScript with themes for React without being tightly coupled to one implementationgithub.com
jsxstyle/jsxstyle
jsxstyle - Inline style system for React and Preactgithub.com

这篇关于9 CSS in JS Libraries You Should Know in 2018的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/496535

相关文章

Vue3 的 shallowRef 和 shallowReactive:优化性能

大家对 Vue3 的 ref 和 reactive 都很熟悉,那么对 shallowRef 和 shallowReactive 是否了解呢? 在编程和数据结构中,“shallow”(浅层)通常指对数据结构的最外层进行操作,而不递归地处理其内部或嵌套的数据。这种处理方式关注的是数据结构的第一层属性或元素,而忽略更深层次的嵌套内容。 1. 浅层与深层的对比 1.1 浅层(Shallow) 定义

JS常用组件收集

收集了一些平时遇到的前端比较优秀的组件,方便以后开发的时候查找!!! 函数工具: Lodash 页面固定: stickUp、jQuery.Pin 轮播: unslider、swiper 开关: switch 复选框: icheck 气泡: grumble 隐藏元素: Headroom

这15个Vue指令,让你的项目开发爽到爆

1. V-Hotkey 仓库地址: github.com/Dafrok/v-ho… Demo: 戳这里 https://dafrok.github.io/v-hotkey 安装: npm install --save v-hotkey 这个指令可以给组件绑定一个或多个快捷键。你想要通过按下 Escape 键后隐藏某个组件,按住 Control 和回车键再显示它吗?小菜一碟: <template

【 html+css 绚丽Loading 】000046 三才归元阵

前言:哈喽,大家好,今天给大家分享html+css 绚丽Loading!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏+关注哦 💕 目录 📚一、效果📚二、信息💡1.简介:💡2.外观描述:💡3.使用方式:💡4.战斗方式:💡5.提升:💡6.传说: 📚三、源代码,上代码,可以直接复制使用🎥效果🗂️目录✍️

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06

在JS中的设计模式的单例模式、策略模式、代理模式、原型模式浅讲

1. 单例模式(Singleton Pattern) 确保一个类只有一个实例,并提供一个全局访问点。 示例代码: class Singleton {constructor() {if (Singleton.instance) {return Singleton.instance;}Singleton.instance = this;this.data = [];}addData(value)

BUUCTF靶场[web][极客大挑战 2019]Http、[HCTF 2018]admin

目录   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 [web][HCTF 2018]admin 考点:弱密码字典爆破 四种方法:   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 访问环境 老规矩,我们先查看源代码

计算机毕业设计 大学志愿填报系统 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

🍊作者:计算机编程-吉哥 🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。 🍊心愿:点赞 👍 收藏 ⭐评论 📝 🍅 文末获取源码联系 👇🏻 精彩专栏推荐订阅 👇🏻 不然下次找不到哟~Java毕业设计项目~热门选题推荐《1000套》 目录 1.技术选型 2.开发工具 3.功能

Vue3项目开发——新闻发布管理系统(六)

文章目录 八、首页设计开发1、页面设计2、登录访问拦截实现3、用户基本信息显示①封装用户基本信息获取接口②用户基本信息存储③用户基本信息调用④用户基本信息动态渲染 4、退出功能实现①注册点击事件②添加退出功能③数据清理 5、代码下载 八、首页设计开发 登录成功后,系统就进入了首页。接下来,也就进行首页的开发了。 1、页面设计 系统页面主要分为三部分,左侧为系统的菜单栏,右侧

Node.js学习记录(二)

目录 一、express 1、初识express 2、安装express 3、创建并启动web服务器 4、监听 GET&POST 请求、响应内容给客户端 5、获取URL中携带的查询参数 6、获取URL中动态参数 7、静态资源托管 二、工具nodemon 三、express路由 1、express中路由 2、路由的匹配 3、路由模块化 4、路由模块添加前缀 四、中间件