Top 5 best UI libraries to Use in your Next Project
Syakir
Posted on July 2, 2024
Introduction
Are you looking to speed up your web development process? A UI library might be just what you need! This article explores the top 5 modern UI libraries that can help you build stunning web applications quickly and efficiently.
A UI library is a collection of pre-designed and pre-built user interface elements (such as Buttons, Menus, Lists, Dropdowns, etc.) used to build user interfaces for a web application in a unified design style.
In a conventional web development workflow, you usually need a UI/UX designer to design the user interfaces before developing a web application. Although this is a good approach, it increases development costs and time. Not all developers can afford that.
Here's where a UI library comes in. It can effectively address this issue by accelerating the web development process and ensuring a visually appealing and consistent design for your web application.
What Makes The Best UI Libraries?
Before we determine the top 5 best UI libraries, it's essential to establish clear criteria. This ensures that our selection process is fair, objective, and accountable, instilling confidence in the validity of our list.
These are the criteria we are using to make this list.
1. It's A UI Library
By the definition we wrote in the Introduction section, it's a UI library. Therefore, we won't include popular libraries like Bootstrap and Tailwindcss because they are more like a CSS framework than a UI Library.
2. Popularity & Community Support
Popularity and community support are significant because the life of a UI library might depend on them. More popular UI libraries have more community support. We will measure this primarily by using Github stars and the number of search results on Google search.
3. Number of Components & Features
This factor indicates the completeness of a UI library. More components & features are better.
4. How Easy to Use and Customize
Each UI library comes with a documentation website and a customization API. We thoroughly reviewed these resources to assess how user-friendly and adaptable the libraries are, particularly for beginners.
5. Accessibility & Performance
Accessibility and Performance make a UI library reliable for production-grade web applications. We measured this by testing the availability of keyboard navigation, WAI-ARIA patterns, and memory consumption of the same components across the tested UI libraries.
6. Developer reviews & experience
A UI library exists to ease developer work. We measured this by our experience using all of them and developer reviews in online forums like Reddit, Stack Overflow, etc.
7. Updates and Development Activity
No one wants to use an outdated library. As of this post, all UI libraries in the list are actively maintained.
1. Material UI - The Most Popular UI Library
Material UI stands as the undisputed champion among UI Libraries built on top of React. It brings Google's Material Design to life with a comprehensive set of components, making it a reliable choice for your projects.
When this article was written, Material UI was in version 5.15.19, with 60+ components, 92.4k GitHub stars, and almost 3k contributors. It is used by 1.2 million projects on Github, and the community support is huge.
How to use Material UI + Examples
You can install Material UI in your project by running:
npm install @mui/material @emotion/react @emotion/styled
After that, you can directly use Material UI component in your project
import * as React from 'react';
import Button from '@mui/material/Button';
export default function ButtonUsage() {
return <Button variant="contained">Hello world</Button>;
}
The image below shows the example implementation of common UI components in Material UI. You can check the live demo and codes in Stackblitz.
Accessibility & Performance
Material UI components follow WAI-ARIA specs and have standard keyword navigation. They are performant, efficient, and reliable for production-grade applications.
While Material UI components are efficient and reliable, they do come with a large bundle size that can potentially impact page speed. However, this can be mitigated by optimizing the bundle size, a process you can learn more about here.
Customization
Material UI has ThemeProvider for basic customization like color palette, dark mode, typography, and breakpoints.
Material UI uses CSS-in-JS library for styling. Every Material UI component has sx
props for inline customization. You can also apply global styling to override the default style.
You can visit Material UI customization docs for more details about customization.
Advantages & Disadvantages
+ Battle-tested UI library.
+ Huge community support.
+ Complete features.
+ Accessible.
± Good for large projects, but overkill for small projects.
- Material Design is overused.
- Customization is not developer friendly.
2. Ant Design - An Enterprise-class React UI library
Ant Design, an open-source design system developed by Alibaba Group for enterprise-class web applications, is known for its simplicity, cleanliness, and elegant UI design. This straightforward design approach can help developers and designers feel at ease when working with the system. It is also built on top of React.
Ant Design is on version 5.18.0 with 75 components, 90.9k GitHub stars, and 2.1k+ contributors when this article is written. It is used by around 605k projects on GitHub.
How to use Ant Design + Examples
You can install Ant Design by running this command:
npm install antd --save
Then, you can use the components in your project
import React from 'react';
import { DatePicker } from 'antd';
const App = () => {
return <DatePicker />;
};
export default App;
The image below shows what Ant Design components look like. You can check the live demo and codes in Stackblitz.
Accessibility & Performance
Ant Design follows basic accessibility specs and supports keyboard navigation for its components. Ant Design components are designed to be clean, performant, and responsive for enterprise-class applications.
Like Material UI, Ant Design uses CSS in JS and has a large bundle size. However, you can optimize it with Tree-shaking.
Customization
Ant Design offers basic customization for theming but limited options for advanced customization. They didn't provide documentation for applying a custom style.
To customize it, you must override the default style with global CSS.
Advantages & Disadvantages
+ Battle-tested UI library.
+ Large community support.
+ Comprehensive components & features.
+ Clean and Elegant design.
± Good for medium-large projects, but overkill for small projects.
- Limited accessibility.
- Limited customization.
3. Mantine - A Fully Featured React UI Library
Mantine is a React UI Library that provides great user and developer experiences. It launched in 2021 and is consistently updated with a new minor release almost monthly, accelerating its growth.
Although Mantine is relatively new compared to Material UI and Ant Design, it offers more complete component collections.
When this article was written, Mantine was on version 7.10.1 with 100+ components, 25.2k GitHub stars, and 531 contributors.
How to use Mantine + Examples
You can install Mantine by running:
npm install @mantine/core @mantine/hooks
You also need to install postcss
.
npm install --save-dev postcss postcss-preset-mantine postcss-simple-vars
Then, create postcss.config.cjs
file in your project root folder.
module.exports = {
plugins: {
'postcss-preset-mantine': {},
'postcss-simple-vars': {
variables: {
'mantine-breakpoint-xs': '36em',
'mantine-breakpoint-sm': '48em',
'mantine-breakpoint-md': '62em',
'mantine-breakpoint-lg': '75em',
'mantine-breakpoint-xl': '88em',
},
},
},
};
You also need to wrap your application with MantineProvider
to be able to use Mantine components.
import { createTheme, MantineProvider } from '@mantine/core';
import '@mantine/core/styles.css';
// core styles are required for all packages
const theme = createTheme({
/** Put your mantine theme override here */
});
function App() {
return (
<MantineProvider theme={theme}>
{/* Your app here */}
</MantineProvider>
);
}
Mantine also provides some starter templates for various frameworks. You can see more details about it in its official documentation.
The image below is a screenshot of the Mantine components implementation. You can check the live demo and codes in Stackblitz.
Accessibility & Performance
Mantine follows WAI-ARIA standards and implements keyboard navigation in its components. Its components are designed with attention to detail and efficiently handle micro-interaction, making them convenient for users.
Starting from version 7, Mantine uses CSS modules for styling, making it faster than the CSS-in-JS-based UI library.
However, this approach also has drawbacks. @mantine/core/styles.css
contains all the component styles. All the unused component styles will also be imported, making a larger bundle size. This problem can be solved by manually importing individual component styles.
Customization
Mantine has a very developer-friendly documentation page that provides live customization for each component.
You can customize Mantine components by passing new CSS modules or modifying component classes and styles through styles API.
Advantages & Disadvantages
+ Complete components and custom hooks.
+ Clean design.
+ Highly customizable.
+ Developer friendly.
± Good for medium-large projects, but overkill for small projects.
- Community support is still small, but growing.
- Bloated CSS from unused components.
4. Chakra UI - Simple, Modular & Accessible UI Library
Chakra UI is a simple and accessible React UI library with composable and highly customizable components. It is also very developer-friendly and easy to use for beginners.
When we wrote this article, Chakra UI's latest stable version was 2.8.2. It has 60+ components, 37k GitHub stars, 600+ contributors, and is used by more than 309,000 projects on GitHub.
How to use Chakra UI + Examples
You can add Chakra UI to your project by running this command:
npm i @chakra-ui/react @emotion/react @emotion/styled framer-motion
You also need to wrap your application root with ChakraProvider
import { ChakraProvider } from '@chakra-ui/react'
function App() {
return (
<ChakraProvider>
<TheRestOfYourApplication />
</ChakraProvider>
)
}
You can go to its official documentation for more details about Chakra UI.
The following image is a screenshot of Chakra UI basic components implementation. You can check the live demo and codes in Stackblitz.
Accessibility & Performance
Every Chakra UI component is built with a WAI-ARIA pattern and documented keyboard navigation support. Generally, Chakra UI components are robust and performant.
In Chakra UI version 2, each component can be imported individually. This ability can decrease the application bundle size, thus improving performance.
Customization
Chakra UI uses CSS-in-JS, offering customization at a slight performance cost. This is due to runtime style computations and className generation, which might be noticeable in performance-sensitive, large apps.
However, Chakra UI is an excellent option for small to medium applications.
Advantages & Disadvantages
+ Highly customizable.
+ Easy to use & developer friendly.
+ Good community support.
+ Accessible & composable components.
± Good for small-medium project.
- Fewer components compared to other UI libraries.
- CSS-in-JS might decrease component performance.
5. Shadcn UI - Beautifully Designed Components
Shadcn UI is a collection of accessible and customizable open-source UI components. Unlike other UI libraries, Shadcn is not available like the npm package. It provides a CLI tool for adding UI component codes directly into your project.
Shadcn is relatively new but quickly gained popularity thanks to its unlimited customization options. Shadcn can be used as a reference for your UI library.
When this article was written, Shadcn had 48 components, 62.8k GitHub stars, and 191 contributors.
How to use Shadcn UI + Examples
Shadcn is dependent on Tailwindcss for styling. So, you need to install Tailwindcss first before installing Shadcn CLI.
To install Shadcn CLI, you can run:
npx shadcn-ui@latest init
There will be a prompt for configuration options.
After that, you can start adding a component code to your project by running:
npx shadcn-ui@latest add button
It will copy button component codes to your component folder, where you can import and use the component.
import { Button } from "@/components/ui/button"
export default function Home() {
return (
<div>
<Button>Click me</Button>
</div>
)
}
There are some additional setups you need to do based on the library you use for your project. It is documented in official installation docs.
The following image is a screenshot of how Shadcn components look like. You can check the live demo and codes in Stackblitz.
Accessibility & Performance
Shadcn components are built on top of Radix UI components and follow WAI-ARIA authoring practices. Radix UI accessibility is tested in many modern browsers and commonly used assistive technologies.
Shadcn components are also efficient and performant. The bundle size is relatively small since you only need to add the components you want to use. It depends on how many elements you use.
Customization
With access to the component codes, Shadcn offers unlimited customization options. You can customize the component classes with Tailwind CSS and even add new props.
Advantages & Disadvantages
+ Accessible and lightweight.
+ Modular.
+ Highly customizable.
+ Clean design.
+ Good for any project, small to large projects.
- Not beginner friendly.
- Still new, Community support still small.
Choosing the Right Library
Because it's one of the best UI libraries, it will only fit some of your project requirements. Before using a UI library, make sure it fits with:
- Your project type and size
- Team member experience
- Your familiarity with the library
- Design compatibility with your brand/project
Conclusion
We researched this post as much as we could to provide an accurate and accountable review, but in the end, the decision is on you. We are just giving you more insights. By reading this article, we hope you can now decide on the UI library that fits your projects.
Posted on July 2, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.