@class101/styled-system

中文文档
5.3.3发布于 2021/11/01MITTypeScriptESM + CJS近 30 天下载 4093

Responsive, theme-based style props for building design systems with React

原始使用文档
文档目录9 节
  1. Features
  2. Try It Out
  3. Table of Contents
  4. Usage
  5. Responsive Style Props
  6. Docs
  7. Further Reading
  8. Built with Styled System
  9. Related

Styled System

Responsive, theme-based style props for building design systems with React https://styled-system.com

stars Build Status Downloads Version spectrum-badge size MIT License system-ui/theme

npm i styled-system

Features

  • Add style props that hook into your own theme
  • Quickly set responsive font-size, margin, padding, width, and more with props
  • Influenced by constraint-based design system principles
  • Typographic scale
  • Spacing scale for margin and padding
  • Works with any color palette
  • Works with most css-in-js libraries, including styled-components & emotion
  • Used in Rebass, Reflexbox, and the Priceline Design System

"This is honestly my favourite way to build UI components right now party parrot"

– Varun Vachhar

"If you haven't seen Styled System before, do yourself a favour and check it out. It's been a huge influence in my thinking on component-oriented styles."

– Mark Dalgleish

"The future of css-in-js is going to look something like styled-system with its responsive values."

– Kye Hohenberger

"Coming from @tachyons_css, the styled-system utilities from @jxnblk is the missing link I’ve been looking for."

– Nathan Young

"If you make websites/apps with React check out Styled System if you haven't already. You will be amazed at how much faster you can build."

– David Yeiser

"If you like Tachyons you will love styled-system. If you don't like Tachyons, you will love styled-system."

– Adam Morse

"Styled System is one of the best libraries I have ever used."

– Miha Sedej

Try It Out

Try the examples on CodeSandbox

Table of Contents

Usage

// Example uses styled-components, but styled-system works with most other css-in-js libraries as well
import styled from 'styled-components'
import { space, layout, typography, color } from 'styled-system'

// Add styled-system functions to your component
const Box = styled.div`
  ${space}
  ${layout}
  ${typography}
  ${color}
`

Each style function exposes its own set of component props that handle styles based on values defined in a theme.

// width: 50%
<Box width={1/2} />

// font-size: 20px (theme.fontSizes[4])
<Box fontSize={4} />

// margin: 16px (theme.space[2])
<Box m={2} />

// padding: 32px (theme.space[3])
<Box p={3} />

// color
<Box color='tomato' />

// color: #333 (theme.colors.gray[0])
<Box color='gray.0' />

// background color
<Box bg='tomato' />

Responsive Style Props

Set responsive width, margin, padding, font-size, and other properties with a shorthand array syntax. Read more

// responsive width
<Box width={[ 1, 1/2, 1/4 ]} />

// responsive font-size
<Box fontSize={[ 2, 3, 4 ]} />

// responsive margin
<Box m={[ 1, 2, 3 ]} />

// responsive padding
<Box p={[ 1, 2, 3 ]} />

To learn more, see the Getting Started guide or read the docs.

Docs


Further Reading

Built with Styled System

MIT License

版本与发布记录

@class101/styled-system 共发布 9 个版本,首次发布于 2021/09/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
5.3.3latest2021/11/015 年前
5.3.22021/11/015 年前
5.3.12021/09/155 年前
5.3.02021/09/155 年前
5.2.32021/09/145 年前
5.2.22021/09/145 年前

其他发布通道:beta → 5.2.1-beta.1。

关于 @class101/styled-system 的常见问题

@class101/styled-system 是什么?

Responsive, theme-based style props for building design systems with React

如何安装 @class101/styled-system?

在项目目录运行 npm install @class101/styled-system,或使用 pnpm add / yarn add / bun add。

@class101/styled-system 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@class101/styled-system 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@class101/styled-system 可以商用吗?

@class101/styled-system 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@class101/styled-system 的下载量有多少?

根据 npm 官方下载统计,@class101/styled-system 在 2026/10/10 – 2026/11/08 这 30 天内被下载 4,093 次,日均约 136 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@class101/styled-system 还在维护吗?

最新版本 5.3.3 发布于 2021/11/01(5 年前);至今共发布 9 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/09/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。