Socket
Socket
Sign inDemoInstall

@styled-system/should-forward-prop

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@styled-system/should-forward-prop

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


Version published
Weekly downloads
176K
increased by7.9%
Maintainers
1
Weekly downloads
 
Created

What is @styled-system/should-forward-prop?

@styled-system/should-forward-prop is a utility for styled-components and emotion that helps filter out props that should not be passed to the DOM element. This is particularly useful when working with styled-system, as it allows you to forward only the necessary props to the styled component, avoiding React warnings and potential issues with invalid HTML attributes.

What are @styled-system/should-forward-prop's main functionalities?

Filtering Props

This feature allows you to filter out props that should not be passed to the DOM element. In this example, the `Box` component will only forward the `margin` and `color` props to the styled component, ensuring that other props are not passed to the DOM.

const shouldForwardProp = require('@styled-system/should-forward-prop');

const Box = styled('div').withConfig({
  shouldForwardProp
})`
  ${space}
  ${color}
`;

<Box margin='16px' color='blue' />

Custom Prop Filtering

This feature allows you to define custom logic for filtering props. In this example, the `CustomBox` component will not forward the `customProp` to the DOM element, but will forward the `margin` and `color` props.

const customShouldForwardProp = (prop) => prop !== 'customProp';

const CustomBox = styled('div').withConfig({
  shouldForwardProp: customShouldForwardProp
})`
  ${space}
  ${color}
`;

<CustomBox customProp='value' margin='16px' color='blue' />

Other packages similar to @styled-system/should-forward-prop

FAQs

Package last updated on 17 Feb 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc