[ Getting started ]

Installation

Install the package, import the stylesheet and render your first component. Includes Tailwind v3/v4 and Next.js setup.

Install the package#

Reusify UI requires React 18 or newer. Install it with your package manager of choice:

$ npm install reusify-ui
$ pnpm add reusify-ui
$ yarn add reusify-ui

Set it up#

  1. 01

    Import the stylesheet once

    Add this line to your entry file (main.jsx, App.jsx or Next.js app/layout.jsx). It contains every component style and both themes.

    src/main.jsx
    import 'reusify-ui/styles.css';
  2. 02

    Use a component

    src/App.jsx
    import { Button } from 'reusify-ui';
    
    export default function App() {
      return <Button onClick={() => alert('Hello!')}>Click me</Button>;
    }
  3. 03

    Optional: add the toast provider

    Only needed if you use toasts. Wrap your app once, then call useToast() anywhere.

    src/main.jsx
    import { ToastProvider } from 'reusify-ui';
    
    createRoot(document.getElementById('root')).render(
      <ToastProvider>
        <App />
      </ToastProvider>,
    );

With Tailwind CSS v4#

Tailwind v4 puts its styles in cascade layers. Import Reusify into its own layer between base and utilities. Preflight can't break the components, and your utility classes can still override them (for example <Progress className="w-80" />).

src/index.css
@layer theme, base, reusify, components, utilities;

@import 'tailwindcss';
@import 'reusify-ui/styles.css' layer(reusify);

/* Optional: make Tailwind's dark: variant follow the same .dark class */
@custom-variant dark (&:where(.dark, .dark *));

Skip the JS import

When you import the stylesheet from CSS like this, don't also import reusify-ui/styles.css in JavaScript. A second, unlayered copy would win over your utilities again.

With Tailwind CSS v3#

Import reusify-ui/styles.css in JavaScript as shown above. Nothing else is needed: no content entry and no plugin. Component styles are written so that Tailwind's preflight can't reset them, whatever order the stylesheets load in.

Next.js (App Router)#

The package ships with a 'use client' directive, so you can import components straight into server components. Import the CSS in your root layout:

app/layout.jsx
import 'reusify-ui/styles.css';
import { ToastProvider } from 'reusify-ui';

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <ToastProvider>{children}</ToastProvider>
      </body>
    </html>
  );
}

Requirements#

  • React and React DOM 18 or newer (peer dependencies).
  • Modern browsers: the styles use color-mix() and CSS custom properties (Chrome 111+, Safari 16.2+, Firefox 113+).
  • Works with Vite, Next.js, Remix, Create React App, Astro (React islands) and any bundler that can import CSS.