Create React Component
This create-react-styled-component
CLI will create a JSX functional component
and a styled-component file. We also included some custom imports for
design tokens and config files in the styled-component to help you on your way.
You need to have installed styled-components
in your own project to use this package.
How to use:create-react-styled-component <name> [option] Options:-V, --version output the version number-t, --tag [type] tag type [default: div]-h, --help output usage information
Install
npm i -g create-react-styled-component-cli
Example
create-react-styled-component Link -t a
Will create this structure
Link |-- Link.jsx |-- style.js
Content of Link.jsx
// Link component// ---------------------------------------------------------------------------- import React from "react";import string bool oneOf node from "prop-types"; import LinkStyle from "./styles"; const propTypes = /** Add prop-types here */ propName: string; const defaultProps = /** Add default prop-types here */ propName: "your-value-here"; const Link = { const children ...rest = props; return <LinkStyle >children</LinkStyle>;}; ; LinkpropTypes = propTypes;LinkdefaultProps = defaultProps;
Content of styles.js
// Style for Link component// ---------------------------------------------------------------------------- ; // Tokens; // Configs;; const LinkStyle = styleda` /* Add style here */`;