8000 GitHub - VedanthB/resuse-ui
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

VedanthB/resuse-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ReuseUI - A Modular UI Component Library and Design System

Description:
ReuseUI is a React + Tailwind CSS component library designed for reusability, accessibility, and scalability. Inspired by MUI, Chakra UI, and Tailwind’s utility-first approach, this library provides modular, flexible, and customizable UI components.


πŸš€ Links


πŸ“Œ Features

βœ… Fully Typed with TypeScript – Provides full IntelliSense support
βœ… Composable and Customizable – Built with compound components for flexibility
βœ… Theming Support – Modify styles using theme overrides
βœ… Accessibility First (A11Y) – WAI-ARIA compliant components
βœ… Vite-Powered – Super-fast build & local development


πŸ“¦ Installation

Install ReuseUI via NPM or Yarn:

npm install reuse-ui
# or
yarn add reuse-ui

Peer Dependencies

Ensure you have React 18+, React-DOM, and Tailwind CSS installed:

npm install react react-dom tailwindcss

πŸ“– Usage

Start using the components by importing them:

import { Button } from "reuse-ui";

export default function App() {
  return (
    <Button color="info" onClick={() => alert("Clicked!")}>
      Click Me
    </Button>
  );
}

Tailwind Setup

Make sure Tailwind is configured in your project. Add this to tailwind.config.js:

module.exports = {
  content: ["./src/**/*.{js,ts,jsx,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
};

πŸ“– Documentation

To run the documentation site locally:

npm run build-docs
npm run preview
  • Deploying to Vercel:
    vercel --prod

πŸ“œ Available Components

Component Description
Button Fully customizable button component
Accordion Expandable/collapsible panels
Modal Dialog box with header, body, footer
Tabs Navigation with multiple tabbed views
Alert Info, warning, success, and error messages
Badge Small status indicators for UI elements
Avatar Profile pictures with different styles
Breadcrumb Navigation breadcrumbs
More... More components being added! πŸš€

πŸ“– See full component docs in Storybook


πŸ“˜ Storybook

View live interactive examples of all components using Storybook:

npm run storybook

To build the Storybook:

npm run build-storybook

πŸ“€ Publishing to NPM

To build and publish the library:

1️⃣ Generate TypeScript Declarations
Ensure your tsconfig.json has:

{
  "compilerOptions": {
    "declaration": true,
    "emitDeclarationOnly": true,
    "outDir": "dist"
  },
  "include": ["src"]
}

Then build:

npm run build

2️⃣ Publish to NPM

npm login
npm publish --access public

πŸ“‚ Project Structure

src/
 β”œβ”€β”€ components/         # UI components
 β”‚   β”œβ”€β”€ Button/
 β”‚   β”œβ”€β”€ Modal/
 β”‚   β”œβ”€β”€ Accordion/
 β”‚   β”œβ”€β”€ ...
 β”œβ”€β”€ docs/               # Documentation
 β”œβ”€β”€ stories/            # Storybook files
 β”œβ”€β”€ utils/              # Helper functions
 β”œβ”€β”€ theme/              # Theming utilities
 β”œβ”€β”€ index.ts            # Export all components

πŸ“š Theming & Customization

To override default styles, use a custom theme:

import { ReuseUI } from "reuse-ui";

const customTheme = {
  button: {
    color: {
      info: "bg-blue-900 text-white hover:bg-blue-700",
    },
  },
};

export default function App() {
  return (
    <ReuseUI theme=
9208
{{ theme: customTheme }}>
      <Button color="info">Custom Info Button</Button>
    </ReuseUI>
  );
}

πŸ“Š Case Study

Why I Built ReuseUI

I wanted to create a React-based UI library that integrates well with Tailwind CSS while following best practices for:

  • Component composition using the Compound Component Pattern.
  • Accessibility (aria-* attributes, keyboard interactions).
  • Full TypeScript support (.d.ts files for IntelliSense).
  • A flexible theming system.

Challenges & Solutions

πŸ›  Centralizing State in Parent Components

  • Problem: Each sub-component managed state separately, causing issues with syncing.
  • Solution: Used context to centralize logic. Example for <Accordion>:
const AccordionContext = createContext({ activePanel: 0, setActivePanel: () => {} });

function Accordion({ children }) {
  const [activePanel, setActivePanel] = useState(0);
  return (
    <AccordionContext.Provider value={{ activePanel, setActivePanel }}>
      {children}
    </AccordionContext.Provider>
  );
}

🎯 Ensuring Full IntelliSense in TypeScript

  • Problem: Some component types weren’t inferred correctly.
  • Solution: Used React.FC and TypeScript Generics:
type ButtonProps = {
  color?: "info" | "success" | "warning";
  onClick: () => void;
};

export const Button: React.FC<ButtonProps> = ({ color = "info", onClick, children }) => (
  <button className={`btn-${color}`} onClick={onClick}>
    {children}
  </button>
);

πŸš€ Roadmap

πŸ”Ή More Components – Progress bars, tooltips, date pickers
πŸ”Ή Better Theming – Dark mode, user presets
πŸ”Ή Drag & Drop Support
πŸ”Ή Improved Docs – More examples, API references


πŸ“ License

This project is licensed under the MIT License. Feel free to use, modify, and contribute!


πŸ’‘ Contributing

Pull requests are welcome! Open an issue if you find bugs or want to request a new feature.


🀝 Support

If you find this library useful, consider starring ⭐ the repo and sharing it!

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0