Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-props-classnames

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-props-classnames

Easily transform component's props to classnames

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by250%
Maintainers
1
Weekly downloads
 
Created
Source

React Props Classnames

Easily transform component's props to classnames

  • Good usage with styled-components when you want to control styles by props.
  • Transform your boolena and string props to className.
  • Customized classNames prefix.

Install

yarn add react-props-classnames

Usage

import styled from 'styled-components';
import createPropsTransform from 'react-props-classnames';

const propsTransform = createPropsTransform();

const Button = styled.button`
  /* ... */

  &.default-prefix-circle {
    /* ... */
  }

  &.default-prefix-size-lg {
    /* ... */
  }
`;

export default propsTransform(Button);
<Button circle size="lg">Button</Button>

// will trasnform to

<button class="{...styled generated} default-prefix-circle default-prefix-size-lg">Button</button>

API

createPropsTransform

keyTypeDefaultDescription
boolBooleantrueTransform boolean props to classNames or not.
stringBooleantrueTransform string props to classNames or not.
prefixString'default-prefix'The prefix of every classNames.

License

MIT © jigsawye

FAQs

Package last updated on 29 May 2018

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