Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Vary styles applied to React components using props

Notifications You must be signed in to change notification settings

ezcater/styled-component-variant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project has been deprecated and will no longer be maintained.

styled-component-variant

A tiny helper to enable you to vary your React components styles based on a prop value.

npm i styled-component-variant

Usage:

import variant from 'styled-component-variant';

const primary = css`
  background-color: 'blue';
`;

const secondary = css`
  background-color: 'orange';
`;

// you can use the theme property in your styles
const tertiary = ({theme}) => css`
  margin: ${theme.spacing.xs2};
`;

const use = variant('use', {
  primary,
  secondary,
  tertiary,
});

const MyButton = styled('button')(use);

// render a blue button
<MyButton use="primary">Click me</MyButton>

// render an orange button
<MyButton use="secondary">Click me</MyButton>

About

Vary styles applied to React components using props

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published