@class101/styled-system__css

中文文档
5.3.3发布于 2021/11/01MITESM + CJS零依赖近 30 天下载 4105

Styled System for the css prop

原始使用文档

@class101/styled-system__css

Styled System for the css prop

npm i @class101/styled-system__css

Styled System CSS lets you write style objects with responsive, theme-aware Styled System shortcuts.

// usage with the css prop
import React from 'react'
import css from '@class101/styled-system__css'

const Beep = props =>
  <div
    {...props}
    css={css({
      fontSize: [4, 5, 6],
      color: 'primary',
    })}
  />
// usage with a styled HOC
import styled from '@emotion/styled'
import css from '@class101/styled-system__css'

const Boop = styled('div')(
  css({
    fontSize: [ 4, 5, 6 ],
    color: 'primary',
    bg: 'gray',
    '&:hover': {
      color: 'secondary',
    },
  })
)

To make the css prop work with styled-components, babel-plugin-styled-components must be enabled.

Theme Keys

The following keys in your style object will work the same as Styled System props, pulling values from your theme object.

PropertyTheme Key
fontFamilyfonts
fontSizefontSizes
fontWeightfontWeights
lineHeightlineHeights
letterSpacingletterSpacings
colorcolors
backgroundColor, bgcolors
margin, mspace
marginTop, mtspace
marginRight, mrspace
marginBottom, mbspace
marginLeft, mlspace
marginX, mxspace
marginY, myspace
padding, pspace
paddingTop, ptspace
paddingRight, prspace
paddingBottom, pbspace
paddingLeft, plspace
paddingX, pxspace
paddingY, pyspace
topspace
bottomspace
leftspace
rightspace
borderborders
borderTopborders
borderRightborders
borderBottomborders
borderLeftborders
borderColorcolors
borderWidthborderWidths
borderStyleborderStyles
borderRadiusradii
boxShadowshadows
textShadowshadows
zIndexzIndices
widthsizes
minWidthsizes
maxWidthsizes
heightsizes
minHeightsizes
maxHeightsizes
sizesizes

Responsive Arrays

All CSS properties accept arrays as values for responsive styles.

<div
  css={css({
    fontSize: [ 4, 5, 6 ],
  })}
/>

In this example, fontSize accepts an array, picking up values from the theme.fontSizes scale, and borderBottom is passed through as plain CSS.

<div
  css={css({
    // Styled System key
    fontSize: [ 3, 4, 5 ],
    // CSS property
    borderBottom: '2px solid tomato',
  })}
/>

MIT License

版本与发布记录

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

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

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

@class101/styled-system__css 是什么?

Styled System for the css prop

如何安装 @class101/styled-system__css?

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

@class101/styled-system__css 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/class101__styled-system__css 是否存在。

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

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

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

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

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

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

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

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