Convert Figma logo to code with AI

chakra-ui logochakra-ui

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

38,137
3,293
38,137
13

Top Related Projects

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

A utility-first CSS framework for rapid UI development.

An enterprise-class UI design language and React UI library

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

17,606

👩‍🎤 CSS-in-JS library designed for high performance style composition

Quick Overview

Chakra UI is a simple, modular, and accessible component library for React applications. It provides a set of customizable and reusable components that help developers build user interfaces quickly and efficiently. Chakra UI is designed with a focus on accessibility, theming, and responsive design.

Pros

  • Highly customizable and themeable components
  • Excellent accessibility support out of the box
  • Responsive design with built-in support for different screen sizes
  • Well-documented with comprehensive guides and examples

Cons

  • Learning curve for developers new to component-based UI libraries
  • Some advanced customizations may require deeper knowledge of the library
  • Limited set of pre-built components compared to some other UI libraries
  • Performance impact when using many components in a large application

Code Examples

  1. Creating a simple button with Chakra UI:
import { Button } from '@chakra-ui/react'

function MyButton() {
  return <Button colorScheme="blue">Click me</Button>
}
  1. Using Chakra UI's responsive styles:
import { Box } from '@chakra-ui/react'

function ResponsiveBox() {
  return (
    <Box
      bg="red.500"
      w={[300, 400, 500]}
      h={['100px', '200px', '300px']}
    >
      Responsive Box
    </Box>
  )
}
  1. Creating a form with Chakra UI components:
import { VStack, Input, Button } from '@chakra-ui/react'

function SimpleForm() {
  return (
    <VStack spacing={4}>
      <Input placeholder="Enter your name" />
      <Input placeholder="Enter your email" type="email" />
      <Button colorScheme="green" type="submit">
        Submit
      </Button>
    </VStack>
  )
}

Getting Started

To start using Chakra UI in your React project, follow these steps:

  1. Install Chakra UI and its peer dependencies:
npm i @chakra-ui/react @emotion/react @emotion/styled framer-motion
  1. Wrap your application with the ChakraProvider:
import { ChakraProvider } from '@chakra-ui/react'

function App() {
  return (
    <ChakraProvider>
      {/* Your app components */}
    </ChakraProvider>
  )
}
  1. Start using Chakra UI components in your application:
import { Button, Box, Text } from '@chakra-ui/react'

function MyComponent() {
  return (
    <Box>
      <Text fontSize="2xl">Welcome to Chakra UI</Text>
      <Button colorScheme="teal">Get Started</Button>
    </Box>
  )
}

Competitor Comparisons

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

Pros of Material-UI

  • More comprehensive component library with a wider range of pre-built components
  • Stronger ecosystem with additional tools and extensions
  • Longer history and larger community, potentially leading to better support and resources

Cons of Material-UI

  • Steeper learning curve due to more complex API and customization options
  • Heavier bundle size, which may impact performance in smaller projects
  • Stricter adherence to Material Design guidelines, potentially limiting design flexibility

Code Comparison

Material-UI:

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

const theme = createTheme();

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

Chakra UI:

import { Button, ChakraProvider } from '@chakra-ui/react';

function App() {
  return (
    <ChakraProvider>
      <Button colorScheme="blue">Click me</Button>
    </ChakraProvider>
  );
}

Both libraries offer component-based UI development with theming capabilities. Material-UI requires more setup with createTheme and ThemeProvider, while Chakra UI provides a simpler approach with ChakraProvider. Material-UI uses specific prop names like variant, whereas Chakra UI uses more intuitive props like colorScheme.

A utility-first CSS framework for rapid UI development.

Pros of Tailwind CSS

  • Highly customizable with a utility-first approach
  • Smaller bundle size due to purging unused styles
  • Rapid prototyping and development with pre-defined classes

Cons of Tailwind CSS

  • Steeper learning curve for developers new to utility-first CSS
  • Can lead to verbose HTML with multiple classes
  • Less out-of-the-box component styling compared to Chakra UI

Code Comparison

Tailwind CSS:

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

Chakra UI:

<Button colorScheme="blue" size="md">
  Button
</Button>

Summary

Tailwind CSS offers a utility-first approach with high customization and smaller bundle sizes, while Chakra UI provides a more component-based structure with pre-styled elements. Tailwind excels in rapid prototyping but may lead to verbose HTML, whereas Chakra UI offers a smoother learning curve with its component library. The choice between the two depends on project requirements and team preferences.

An enterprise-class UI design language and React UI library

Pros of Ant Design

  • More comprehensive component library with a wider range of pre-built components
  • Stronger enterprise-level design system with consistent patterns and guidelines
  • Better support for complex data visualization and form handling

Cons of Ant Design

  • Steeper learning curve due to its extensive API and configuration options
  • Less flexibility in customization compared to Chakra UI's more modular approach
  • Larger bundle size, which may impact initial load times for applications

Code Comparison

Ant Design button example:

import { Button } from 'antd';

const MyButton = () => (
  <Button type="primary" size="large">
    Click me
  </Button>
);

Chakra UI button example:

import { Button } from '@chakra-ui/react';

const MyButton = () => (
  <Button colorScheme="blue" size="lg">
    Click me
  </Button>
);

Both libraries offer similar component APIs, but Ant Design often requires more specific prop names (e.g., type="primary") while Chakra UI uses more generic props (e.g., colorScheme="blue"). Chakra UI's approach allows for easier customization and theme integration, while Ant Design's specific props ensure consistency with its design system.

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

Pros of styled-components

  • More flexible and powerful CSS-in-JS solution
  • Better support for dynamic styling based on props
  • Easier to create and manage complex component styles

Cons of styled-components

  • Steeper learning curve for developers new to CSS-in-JS
  • Potentially larger bundle size due to runtime styling
  • Lack of pre-built components and design system

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;
`;

Chakra UI:

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

<Button colorScheme="blue" variant={primary ? "solid" : "outline"}>
  Click me
</Button>

styled-components offers more flexibility in styling, allowing for complex CSS logic within the template literal. Chakra UI provides a more structured approach with pre-defined props and variants, making it easier to maintain consistency across the application but potentially limiting customization options.

17,606

👩‍🎤 CSS-in-JS library designed for high performance style composition

Pros of Emotion

  • More flexible and lightweight, allowing for custom styling solutions
  • Better performance due to smaller bundle size and optimized runtime
  • Supports object styles, which can be easier for some developers to work with

Cons of Emotion

  • Requires more setup and configuration compared to Chakra UI's out-of-the-box components
  • Less opinionated, which may lead to inconsistent designs across teams
  • Steeper learning curve for developers new to CSS-in-JS

Code Comparison

Emotion:

import { css } from '@emotion/react'

const style = css`
  background-color: hotpink;
  &:hover {
    color: blue;
  }
`

Chakra UI:

import { Box } from '@chakra-ui/react'

<Box
  bg="hotpink"
  _hover={{ color: 'blue' }}
>
  Hello
</Box>

Emotion provides more granular control over styles, while Chakra UI offers a more declarative approach with pre-built components and utility props. Chakra UI is built on top of Emotion, combining its power with a comprehensive component library and design system.

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

Chakra logo

Build Accessible React Apps with Speed ⚡️


Bundle Size Github Checks MIT License NPM Downloads Github Stars Discord


Chakra UI is a component system for building products with speed. Accessible React components for building high-quality web apps and design systems. Works with Next.js RSC

Documentation

It's the https://chakra-ui.com website for the latest version of Chakra UI.

Installation

To use Chakra UI components, all you need to do is install the @chakra-ui/react package and its peer dependencies:

# with Yarn
$ yarn add @chakra-ui/react @emotion/react

# with npm
$ npm i @chakra-ui/react @emotion/react

# with pnpm
$ pnpm add @chakra-ui/react @emotion/react

# with Bun
$ bun add @chakra-ui/react @emotion/react

Usage

Read the docs here: https://www.chakra-ui.com/docs/get-started/installation

Contributing

Read the contribution guide here: https://www.chakra-ui.com/docs/get-started/contributing

Support Chakra UI

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

Individuals

By donating $5 or more you can support the ongoing development of this project. We'll appreciate some support. Thank you to all our supporters! 🙏 [Contribute]

Testimonials

People throw React component libraries and design systems at me regularly. This might be the best one I've seen. The APIs are simple but composable and the accessibility on the couple components I looked is complete.

Great work @thesegunadebayo, really inspiring work. – Ryan Florence

Awesome new open-source component library from @thesegunadebayo. Really impressive stuff! – Colm Tuite

This is incredible work. Amazing job Segun! – Lee Robinson

Chakra UI is glorious! I love the consistent use of focus styling and the subtle animation – Guillermo ▲

Awards and Mentions

We've been extremely humbled to receive awards and mentions from the community for all the innovation and reach Chakra UI brings to the JavaScript ecosystem.

Technology Radar

Solution Worth Pursuing

Technology Radar (2020–2021)

Open Source Awards 2020

The Most Impactful Contribution to the community

Open Source Awards (2020)

License

MIT © Segun Adebayo

NPM DownloadsLast 30 Days