tw-styled
v3.0.0
Published
 [](https://codecov.io/gh/zhangyu1818/tw-styled)  => (
<div className={className}>Function Component</div>
)
const StyledComponent = tw(
Component,
)`bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded`
Using Components in Your Project
You can now use the styled component just like any other React component:
function App() {
return (
<div className='App'>
<Button>Click me</Button>
</div>
)
}
Using tw-styled
with custom classnames merge functionality
import { create } from 'tw-styled/create'
const merge = (classNames, propsClassNames) =>
`${classNames} ${propsClassNames}`
const tw = create(merge)
API
tw
A Proxy object for creating styled components with Tailwind CSS utility classes. It supports all HTML tags and React function components.
Usage
const StyledComponent = tw.Tag`tailwind-class-names`
const StyledComponent = tw.Tag('tailwind-class-names')
const FunctionComponent = ({ className }) => (
<div className={className}>Function Component</div>
)
const StyledComponent = tw(FunctionComponent)`tailwind-class-names`
const StyledComponent = tw(FunctionComponent)('tailwind-class-names')
- Tag: An HTML tag (like
div
,span
,button
) or a React function component. - tailwind-class-names: A Template String of Tailwind CSS classes.
Contributing
Contributions are always welcome! If you have any suggestions, issues, or want to make improvements, please feel free to open an issue or submit a pull request.
License
MIT