Socket
Socket
Sign inDemoInstall

@ant-design/cssinjs

Package Overview
Dependencies
14
Maintainers
7
Versions
115
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ant-design/cssinjs

Component level cssinjs resolution for antd


Version published
Maintainers
7
Install size
2.13 MB
Created

Readme

Source

@ant-design/cssinjs

NPM version npm download dumi build status Codecov bundle size

Component level cssinjs solution used in ant.design. It's a subset of Emotion with design token logic wrapper. Please feel free to use emotion directly if you want to find a web cssinjs solution. cssinjs related dep packages:

  • stylis
  • @emotion/hash
  • @emotion/unitless

Live Demo

https://ant-design.github.io/cssinjs/

Install

npm install @ant-design/cssinjs

or

yarn add @ant-design/cssinjs
pnpm add @ant-design/cssinjs

Development

npm install
npm start

License

@ant-design/cssinjs is released under the MIT license.

API

StyleProvider

PropDescTypeDefault
autoClearClear inject style element when component remove.booleanfalse
cacheConfig cssinjs cache entity. Only set when you need ssr to extract style on you own.CacheEntity-
hashPriorityUse :where selector to reduce hashId css selector priority'low' | 'high''low'
containerTell cssinjs where to inject style in.Element | ShadowRootdocument.head
ssrInlineComponent wil render inline <style /> for fallback in SSR. Not recommend.booleanfalse
transformersTransform css before inject in document. Please note that transformers do not support dynamic updateTransformer[]-

createCache

return CacheEntity for StyleProvider.

createTheme

Create theme object. When same algorithm provided, it will return same object.

Since @ant-design/cssinjs use strong constraints for cache hit performance, we recommend to view demo basic.tsx for usage and animation.tsx for animation usage.

Transform

When you need transform CSSObject before inject style. You can use transformers to handle this:

import {
  legacyLogicalPropertiesTransformer,
  StyleProvider,
} from '@ant-design/cssinjs';

export default () => (
  <StyleProvider transformers={[legacyLogicalPropertiesTransformer]}>
    <MyApp />
  </StyleProvider>
);

Follow are the transform we provide:

legacyLogicalPropertiesTransformer

Convert logical properties to legacy properties. e.g. marginBlockStart to marginTop:

  • inset
  • margin
  • padding
  • border
px2remTransformer

Convert pixel units to rem units. px2remTransformer.options

Keywords

FAQs

Last updated on 22 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc