This repository contains a collection of reusable React components styled with Tailwind CSS. The components are designed to be easily integrated into your React projects, providing a consistent and visually appealing user interface.
To use this component library in your project, you can install it via npm or yarn.
npm install @wedevs/tail-react
# or
yarn add @wedevs/tail-reactOn your app.css file, add the source file:
+ @source './node_modules/@wedevs/tail-react/dist/index.{js,ts,jsx,tsx}';On your tailwind.config.js file, update the content entry:
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
+ "node_modules/@wedevs/tail-react/dist/index.js"
],
theme: {
extend: {},
},
plugins: [
+ import('@tailwindcss/forms'),
],
}By default, the component library uses indigo as the primary color. You can customize this using the TailReactBaseColorProvider:
import { TailReactBaseColorProvider, Button } from '@wedevs/tail-react';
function App() {
return (
<TailReactBaseColorProvider color="blue">
{/* All components inside will use blue as the primary color */}
<Button variant="primary">Primary Blue Button</Button>
</TailReactBaseColorProvider>
);
}Available color options include all Tailwind CSS colors:
slate,gray,zinc,neutral,stonered,orange,amber,yellow,limegreen,emerald,teal,cyan,skyblue,indigo(default),violet,purple,fuchsiapink,rose
When using dynamic color classes with TailReactBaseColor context in Tailwind CSS v3, you need to safelist these classes in your Tailwind config to prevent them from being purged in production:
// tailwind.config.js
module.exports = {
// ... your existing config
safelist: [
// Safelist color variants that you plan to use dynamically
{
pattern: /bg-(red|blue|green|purple|indigo|etc)-(500|600|700)/,
},
{
pattern: /text-(red|blue|green|purple|indigo|etc)-(500|600)/,
},
{
pattern: /ring-(red|blue|green|purple|indigo|etc)-(400|500|600)/,
},
// Add other patterns based on which color utilities you use
],
// ... rest of your config
};This approach allows you to safelist utility classes using patterns, which is much more concise than listing each class individually.
To get started with development:
- Clone the repository
- Install dependencies:
npm install
- Start the development server:
npm run dev
- Build the library:
npm run build
- Run Storybook:
npm run storybook