@styled-system/should-forward-prop
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/styled-system__should-forward-prop package

5.1.5 • Public • Published

@styled-system/should-forward-prop

Utility for filtering Styled System props with Emotion's shouldForwardProp option

npm i @styled-system/should-forward-prop
import styled from '@emotion/styled'
import {
  space,
  color,
  typography
} from 'styled-system'
import shouldForwardProp from '@styled-system/should-forward-prop'

const Box = styled('div', { shouldForwardProp })(
  space,
  color,
  typography
)

Custom Props

To exclude other custom props not included in Styled System, use the createShouldForwardProp utility.

import styled from '@emotion/styled'
import { space, color } from 'styled-system'
import { createShouldForwardProp, props } from '@styled-system/should-forward-prop'

const shouldForwardProp = createShouldForwardProp([
  ...props,
  'd',
  'x'
])

const Box = styled('div', {
  shouldForwardProp
})(props => ({
  display: props.d,
  fontWeight: props.x ? 'bold' : null,
}),
  space,
  color
)

MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i @styled-system/should-forward-prop

Weekly Downloads

152,588

Version

5.1.5

License

MIT

Unpacked Size

5.54 kB

Total Files

7

Last publish

Collaborators

  • jxnblk