Convert Figma logo to code with AI

shadcn-ui logoui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.

68,588
4,067
68,588
975

Top Related Projects

A utility-first CSS framework for rapid UI development.

37,442

⚡️ Simple, Modular & Accessible UI Components for your React Applications

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

An enterprise-class UI design language and React UI library

83,945

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation

Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅

Quick Overview

shadcn-ui/ui is a collection of re-usable components built using Radix UI and Tailwind CSS. It provides a set of accessible, customizable, and beautifully designed UI components that can be easily integrated into React applications. The project aims to offer a balance between flexibility and convenience for developers.

Pros

  • Highly customizable components with Tailwind CSS
  • Built on top of Radix UI, ensuring accessibility and robust functionality
  • Easy to copy and paste individual components into projects
  • Regularly updated and maintained

Cons

  • Not a traditional npm package, requiring manual integration of components
  • Learning curve for developers unfamiliar with Radix UI or Tailwind CSS
  • Limited number of components compared to some full-featured UI libraries
  • Potential for inconsistency across projects due to individual component copying

Code Examples

  1. Button component usage:
import { Button } from "@/components/ui/button"

export function ButtonExample() {
  return (
    <Button variant="outline" size="lg">
      Click me
    </Button>
  )
}
  1. Dialog component usage:
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"

export function DialogExample() {
  return (
    <Dialog>
      <DialogTrigger>Open Dialog</DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Are you sure?</DialogTitle>
          <DialogDescription>
            This action cannot be undone.
          </DialogDescription>
        </DialogHeader>
      </DialogContent>
    </Dialog>
  )
}
  1. Select component usage:
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select"

export function SelectExample() {
  return (
    <Select>
      <SelectTrigger className="w-[180px]">
        <SelectValue placeholder="Theme" />
      </SelectTrigger>
      <SelectContent>
        <SelectItem value="light">Light</SelectItem>
        <SelectItem value="dark">Dark</SelectItem>
        <SelectItem value="system">System</SelectItem>
      </SelectContent>
    </Select>
  )
}

Getting Started

  1. Clone the repository:

    git clone https://github.com/shadcn-ui/ui.git
    
  2. Copy the components you need into your project's components/ui directory.

  3. Install the required dependencies:

    npm install @radix-ui/react-* tailwindcss-animate class-variance-authority clsx tailwind-merge
    
  4. Configure your tailwind.config.js to include the necessary plugins and content paths.

  5. Import and use the components in your React application as shown in the code examples above.

Competitor Comparisons

A utility-first CSS framework for rapid UI development.

Pros of Tailwind CSS

  • More flexible and customizable, allowing for fine-grained control over styles
  • Larger community and ecosystem, with extensive documentation and third-party resources
  • Can be used with any JavaScript framework or vanilla HTML

Cons of Tailwind CSS

  • Steeper learning curve, requiring familiarity with utility classes and configuration
  • Can lead to verbose HTML markup, potentially reducing readability
  • Requires additional setup and configuration for optimal use

Code Comparison

Tailwind CSS:

<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
  Click me
</button>

shadcn/ui:

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

<Button>Click me</Button>

Summary

Tailwind CSS offers more flexibility and customization options, making it suitable for a wide range of projects. It has a larger community and can be used with any framework. However, it requires more setup and has a steeper learning curve.

shadcn/ui provides pre-built components that are easier to use out of the box, resulting in cleaner code. It's more opinionated and less flexible but offers a faster development experience for React projects.

Choose Tailwind CSS for maximum flexibility and customization, or shadcn/ui for rapid development with pre-styled components in React applications.

37,442

⚡️ Simple, Modular & Accessible UI Components for your React Applications

Pros of Chakra UI

  • Comprehensive component library with a wide range of pre-built components
  • Extensive theming capabilities and customization options
  • Strong accessibility features built-in by default

Cons of Chakra UI

  • Larger bundle size due to its comprehensive nature
  • Steeper learning curve for beginners due to its extensive API
  • Less flexibility in terms of styling compared to more utility-based approaches

Code Comparison

Chakra UI:

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

<Box bg="tomato" w="100%" p={4} color="white">
  <Text fontSize="xl">This is a box</Text>
</Box>

shadcn/ui:

import { Card, CardContent } from "@/components/ui/card"

<Card className="bg-red-500 w-full p-4 text-white">
  <CardContent>
    <p className="text-xl">This is a card</p>
  </CardContent>
</Card>

The main difference is that Chakra UI uses its own prop-based styling system, while shadcn/ui relies more on utility classes and custom components. Chakra UI's approach can lead to more concise component usage, but shadcn/ui offers more flexibility in styling and integration with existing CSS frameworks.

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 components
  • Strong ecosystem with additional tools, plugins, and community support
  • Comprehensive documentation and examples for easy implementation

Cons of Material-UI

  • Larger bundle size due to the extensive component library
  • Steeper learning curve for customization and theming
  • More opinionated design system, which may limit flexibility

Code Comparison

Material-UI:

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

function MyComponent() {
  return <Button variant="contained">Click me</Button>;
}

shadcn/ui:

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

function MyComponent() {
  return <Button>Click me</Button>
}

Material-UI uses a more structured approach with predefined variants, while shadcn/ui offers a simpler, more customizable implementation. shadcn/ui's components are typically more lightweight and easier to modify, but may require more manual styling. Material-UI provides a more complete out-of-the-box solution with consistent styling across components, but can be more challenging to customize extensively.

An enterprise-class UI design language and React UI library

Pros of Ant Design

  • Comprehensive component library with a wide range of pre-built components
  • Extensive documentation and community support
  • Built-in internationalization support

Cons of Ant Design

  • Larger bundle size due to the extensive component library
  • Less flexibility in customization compared to shadcn/ui's utility-first approach
  • Steeper learning curve for developers new to the ecosystem

Code Comparison

Ant Design (Button component):

import { Button } from 'antd';

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

shadcn/ui (Button component):

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

const MyComponent = () => (
  <Button variant="default">Click me</Button>
);

Key Differences

  • Ant Design provides a complete design system with predefined styles, while shadcn/ui offers more customizable components
  • shadcn/ui uses Tailwind CSS for styling, allowing for easier customization and smaller bundle sizes
  • Ant Design has a more opinionated design language, whereas shadcn/ui provides more flexibility in visual design

Use Cases

  • Ant Design: Ideal for large-scale enterprise applications requiring a consistent design system
  • shadcn/ui: Better suited for projects needing high customization and smaller bundle sizes
83,945

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation

Pros of Storybook

  • Comprehensive documentation and development environment for UI components
  • Supports multiple frameworks and libraries (React, Vue, Angular, etc.)
  • Extensive ecosystem with addons for testing, accessibility, and more

Cons of Storybook

  • Steeper learning curve and more complex setup
  • Can be overkill for smaller projects or simpler component libraries
  • Requires additional configuration for advanced features

Code Comparison

Storybook component story:

import { Button } from './Button';

export default {
  title: 'Example/Button',
  component: Button,
};

const Template = (args) => <Button {...args} />;

export const Primary = Template.bind({});
Primary.args = {
  primary: true,
  label: 'Button',
};

shadcn/ui component usage:

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

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

While Storybook provides a robust development environment for UI components with extensive features, shadcn/ui offers a simpler, more lightweight approach to component libraries. Storybook excels in larger projects with complex component ecosystems, whereas shadcn/ui is ideal for quick implementation and customization of pre-built components in smaller to medium-sized projects.

Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅

Pros of styled-components

  • Offers dynamic styling based on props, enabling more flexible and reusable components
  • Provides automatic vendor prefixing and unique class names, reducing CSS conflicts
  • Supports full CSS syntax, including nested selectors and media queries

Cons of styled-components

  • Requires additional setup and learning curve for developers new to CSS-in-JS
  • Can lead to larger bundle sizes due to runtime styling calculations
  • May have performance implications for complex applications with many styled components

Code Comparison

styled-components:

const Button = styled.button`
  background-color: ${props => props.primary ? 'blue' : 'white'};
  color: ${props => props.primary ? 'white' : 'blue'};
  padding: 10px 20px;
  border: 2px solid blue;
`;

shadcn/ui:

<Button variant="default">
  Default
</Button>
<Button variant="destructive">
  Destructive
</Button>

styled-components offers more flexibility in styling directly within component definitions, while shadcn/ui provides pre-built, customizable components with predefined variants. The choice between the two depends on project requirements, team preferences, and the desired level of customization and maintainability.

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

shadcn/ui

Accessible and customizable components that you can copy and paste into your apps. Free. Open Source. Use this to build your own component library.

hero

Documentation

Visit http://ui.shadcn.com/docs to view the documentation.

Contributing

Please read the contributing guide.

License

Licensed under the MIT license.