Convert Figma logo to code with AI

daisyui logoreact-daisyui

daisyUI components built with React 🌼

1,014
112
1,014
24

Top Related Projects

Completely unstyled, fully accessible UI components, designed to integrate beautifully with Tailwind CSS.

86,031

A set of beautifully-designed, accessible components and a code distribution platform. Works with your favorite frameworks. Open Source. Open Code.

38,784

Chakra UI is a component system for building products with speed ⚡️

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.

An enterprise-class UI design language and React UI library

Bootstrap components built with React

Quick Overview

React-daisyui is a React component library that implements the DaisyUI components and utility classes. It provides a set of pre-built, customizable React components that follow the DaisyUI design system, making it easier for developers to create beautiful and consistent user interfaces in React applications.

Pros

  • Seamless integration with React projects
  • Extensive collection of pre-built components
  • Customizable and themeable
  • Built on top of Tailwind CSS, providing flexibility and utility

Cons

  • Dependency on both React and Tailwind CSS
  • Learning curve for developers unfamiliar with DaisyUI or Tailwind CSS
  • Limited documentation compared to more established component libraries
  • Potential performance overhead due to the use of Tailwind CSS

Code Examples

  1. Using a Button component:
import { Button } from 'react-daisyui'

function MyComponent() {
  return (
    <Button color="primary" size="lg">
      Click me!
    </Button>
  )
}
  1. Creating a modal dialog:
import { Modal, Button } from 'react-daisyui'

function MyModal() {
  const [visible, setVisible] = useState(false)

  return (
    <>
      <Button onClick={() => setVisible(true)}>Open Modal</Button>
      <Modal open={visible} onClickBackdrop={() => setVisible(false)}>
        <Modal.Header>Modal Title</Modal.Header>
        <Modal.Body>This is the modal content.</Modal.Body>
      </Modal>
    </>
  )
}
  1. Implementing a card component:
import { Card } from 'react-daisyui'

function MyCard() {
  return (
    <Card>
      <Card.Image src="https://example.com/image.jpg" alt="Card image" />
      <Card.Body>
        <Card.Title>Card Title</Card.Title>
        <p>This is the card content.</p>
        <Card.Actions>
          <Button>Action</Button>
        </Card.Actions>
      </Card.Body>
    </Card>
  )
}

Getting Started

To use react-daisyui in your React project:

  1. Install the package:
npm install react-daisyui
  1. Make sure you have Tailwind CSS installed and configured in your project.

  2. Import and use components in your React code:

import { Button, Card } from 'react-daisyui'

function App() {
  return (
    <div>
      <Button>Click me</Button>
      <Card>
        <Card.Body>Hello, world!</Card.Body>
      </Card>
    </div>
  )
}
  1. (Optional) Configure themes by following the DaisyUI theming documentation.

Competitor Comparisons

Completely unstyled, fully accessible UI components, designed to integrate beautifully with Tailwind CSS.

Pros of Headless UI

  • Highly customizable and flexible, allowing for more control over styling and behavior
  • Lightweight and focused on accessibility and keyboard navigation
  • Seamless integration with Tailwind CSS for efficient styling

Cons of Headless UI

  • Requires more initial setup and configuration compared to React DaisyUI
  • Less out-of-the-box styling, which may increase development time for some projects
  • Steeper learning curve for developers new to headless UI concepts

Code Comparison

Headless UI (Dropdown example):

import { Menu } from '@headlessui/react'

function MyDropdown() {
  return (
    <Menu>
      <Menu.Button>Options</Menu.Button>
      <Menu.Items>
        <Menu.Item>
          {({ active }) => (
            <a className={`${active && 'bg-blue-500'}`} href="/account-settings">
              Account settings
            </a>
          )}
        </Menu.Item>
        {/* More menu items */}
      </Menu.Items>
    </Menu>
  )
}

React DaisyUI (Dropdown example):

import { Dropdown } from 'react-daisyui'

function MyDropdown() {
  return (
    <Dropdown>
      <Dropdown.Toggle>Click</Dropdown.Toggle>
      <Dropdown.Menu className="w-52">
        <Dropdown.Item>Item 1</Dropdown.Item>
        <Dropdown.Item>Item 2</Dropdown.Item>
      </Dropdown.Menu>
    </Dropdown>
  )
}
86,031

A set of beautifully-designed, accessible components and a code distribution platform. Works with your favorite frameworks. Open Source. Open Code.

Pros of shadcn-ui

  • Highly customizable with a focus on flexibility and extensibility
  • Built with modern React patterns and Radix UI primitives
  • Offers a CLI tool for easy component installation and customization

Cons of shadcn-ui

  • Requires more setup and configuration compared to React DaisyUI
  • Smaller component library with fewer pre-built elements
  • Steeper learning curve for developers new to Radix UI concepts

Code Comparison

shadcn-ui:

import { Button } from "@/components/ui/button"

export function Example() {
  return <Button variant="outline">Click me</Button>
}

React DaisyUI:

import { Button } from "react-daisyui"

export function Example() {
  return <Button color="primary">Click me</Button>
}

Both libraries offer React components for UI elements, but shadcn-ui focuses on customization and modern React patterns, while React DaisyUI provides a larger set of pre-styled components based on the DaisyUI CSS framework. shadcn-ui requires more setup but offers greater flexibility, while React DaisyUI is easier to get started with but may be less customizable for complex projects.

38,784

Chakra UI is a component system for building products with speed ⚡️

Pros of Chakra UI

  • More extensive component library with a wider range of pre-built components
  • Better documentation and community support
  • Highly customizable with a powerful theming system

Cons of Chakra UI

  • Larger bundle size, which may impact initial load times
  • Steeper learning curve due to its extensive API and features
  • Less opinionated design, requiring more effort to achieve a cohesive look

Code Comparison

Chakra UI:

import { Box, Button, Text } from "@chakra-ui/react"

function Example() {
  return (
    <Box bg="gray.100" p={4}>
      <Text fontSize="xl">Hello, Chakra UI!</Text>
      <Button colorScheme="blue">Click me</Button>
    </Box>
  )
}

React DaisyUI:

import { Card, Button } from "react-daisyui"

function Example() {
  return (
    <Card className="bg-base-200 p-4">
      <p className="text-xl">Hello, DaisyUI!</p>
      <Button color="primary">Click me</Button>
    </Card>
  )
}

Both libraries offer component-based approaches, but Chakra UI uses its own styling system, while React DaisyUI leverages Tailwind CSS classes for styling. Chakra UI provides more granular control over component properties, while React DaisyUI offers a simpler API with pre-defined styles.

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.

Pros of Material-UI

  • Extensive component library with a wide range of pre-built UI elements
  • Strong TypeScript support and comprehensive documentation
  • Large and active community, providing frequent updates and support

Cons of Material-UI

  • Steeper learning curve due to its complex API and customization options
  • Larger bundle size, which may impact initial load times for applications
  • Opinionated design system that may require more effort to customize

Code Comparison

Material-UI:

import { Button, TextField } from '@mui/material';

<Button variant="contained" color="primary">
  Click me
</Button>
<TextField label="Enter text" variant="outlined" />

React DaisyUI:

import { Button, Input } from 'react-daisyui';

<Button color="primary">Click me</Button>
<Input placeholder="Enter text" />

Both libraries offer similar components, but Material-UI provides more built-in variants and customization options out of the box. React DaisyUI, on the other hand, offers a simpler API and relies more on utility classes for styling and customization.

An enterprise-class UI design language and React UI library

Pros of Ant Design

  • More comprehensive component library with a wider range of UI elements
  • Extensive documentation and community support
  • Built-in internationalization support

Cons of Ant Design

  • Larger bundle size, which may impact performance
  • Less customizable styling compared to DaisyUI's utility-first approach
  • Steeper learning curve due to its extensive API

Code Comparison

Ant Design:

import { Button } from 'antd';

const MyComponent = () => (
  <Button type="primary">Click me</Button>
);

React DaisyUI:

import { Button } from 'react-daisyui';

const MyComponent = () => (
  <Button color="primary">Click me</Button>
);

Summary

Ant Design offers a more comprehensive set of components and features, making it suitable for large-scale enterprise applications. It provides extensive documentation and community support, which can be beneficial for developers working on complex projects.

On the other hand, React DaisyUI is more lightweight and focuses on utility-first styling, allowing for easier customization. It has a smaller bundle size and a simpler API, making it a good choice for smaller projects or developers who prefer more control over styling.

The code comparison shows that both libraries offer similar basic usage, with slight differences in prop naming conventions. Ant Design uses type for button variants, while React DaisyUI uses color.

Bootstrap components built with React

Pros of react-bootstrap

  • More mature and established project with a larger community
  • Extensive documentation and examples
  • Wider range of components available out-of-the-box

Cons of react-bootstrap

  • Heavier bundle size compared to react-daisyui
  • Less customizable without additional CSS overrides
  • Styling is more opinionated and may require more effort to achieve a unique look

Code Comparison

react-bootstrap:

import { Button } from 'react-bootstrap';

<Button variant="primary">Click me</Button>

react-daisyui:

import { Button } from 'react-daisyui';

<Button color="primary">Click me</Button>

Both libraries offer similar component APIs, but react-daisyui tends to have more customization options available through props. react-bootstrap follows Bootstrap's class-based approach more closely, while react-daisyui leverages Tailwind CSS classes for styling.

react-bootstrap is a solid choice for projects that require a traditional Bootstrap look or need a wide range of pre-built components. react-daisyui, on the other hand, offers more flexibility in terms of customization and a lighter footprint, making it suitable for projects that prioritize unique designs and performance.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

daisyUI components built with React, Typescript and TailwindCSS

[ See all components ]

card-3

react-daisyui 🌼

NPM Version npm bundle size npm License Discord Invite

📖 Check out our Storybook | 🎲 Try it with CodeSandbox

🙋 Need help or have a suggestion? Join our discord!


💿 Install

Make sure you've installed TailwindCSS and daisyUI.

Install the package with npm or yarn:

npm install react-daisyui
or
yarn add react-daisyui

To prevent TailwindCSS from purging your styles, add the following line to your tailwind.config.js:

module.exports = {
  content: [
    'node_modules/daisyui/dist/**/*.js',
    'node_modules/react-daisyui/dist/**/*.js',
  ],
  plugins: [require('daisyui')],
}
For Next.js 13 - 14:

Modify transpilePackages in your next.config.js file:

const nextConfig = {
  // ... your content here
  transpilePackages: ['react-daisyui'],
  reactStrictMode: true,
}

module.exports = nextConfig
For Next.js 12: Install next-transpile modules:
npm install next-transpile-modules

And import the package inside your next.config.js file:

const withTM = require('next-transpile-modules')(['react-daisyui'])

Finally, you can wrap your module.exports using withTM like so:

module.exports = withTM({
  //... your content here
  reactStrictMode: true,
})

⚡ Quick Start

Import react-daisyui components within your component files:

import { Button } from 'react-daisyui'

export default (props) => {
  return <Button color="primary">Click me!</Button>
}

🎨 Themes

To apply a theme (or multiple themes) to a page or components, import the Theme component and wrap your content:

import { Theme, Button } from 'react-daisyui'

export default (props) => {
  return (
    <>
      <Theme dataTheme="dark">
        <Button color="primary">Click me, dark!</Button>
      </Theme>

      <Theme dataTheme="light">
        <Button color="primary">Click me, light!</Button>
      </Theme>
    </>
  )
}

Use tools like the official daisyUI Theme Generator or daisyUI Theme Builder to easily create your own themes.


⚙️ Components

Actions:
Data Display:
Navigation:
Feedback:
Data Input:
Layout:
Mockup:

🤝 Contributing

We're looking for contributors to help write stories and unit tests for components.

Creating new components

Run npm run generate component ${your_new_component_name}. The generator will ask a few questions and setup the component for you.

When you'e done, export the component from index.tsx and open a PR.

Creating new stories

Check out the official daisyUI examples. 👈


License

This project is licensed under the MIT License - see the LICENSE.md file for details.

NPM DownloadsLast 30 Days