Installation
Requirements:
- React 18 or later
- Tailwind CSS 3.4 or later
- Framer Motion 11.9 or later
Automatic Installation
Using the CLI is now the easiest way to start a NextUI project. You can initialize your project and add components directly via the CLI:
Installation
Execute one of the following commands in your terminal:
Initialization and Starting the App
Initialize the project by using the init
command.
You will be prompted to configure your project:
Install the dependencies to start the local server:
Start the local server:
Adding the Components
Once your NextUI project is ready to develop, you can add individual components using the CLI. For example, to add a button component:
This command adds the Button component to your project and manages all related dependencies.
You can also add multiple components at once:
Or you can add the main library @nextui-org/react
by running the following command:
If you leave out the component name, the CLI will prompt you to select the components you want to add.
Manual Installation
If you prefer not to use the CLI, you may try either global installation or individual installation to set up NextUI in your project:
Global Installation
The easiest way to get started with NextUI is to use the global installation, which means that all the components are imported from a single package.
Follow the steps below to install all NextUI components:
Install Packages
To install NextUI, run one of the following commands in your terminal:
Hoisted Dependencies Setup
Note: This step is only for those who use
pnpm
to install. If you install NextUI using other package managers, you may skip this step.
If you are using pnpm, you need to add the following line to your .npmrc
file to hoist our packages to the root node_modules
.
After modifying the .npmrc
file, you need to run pnpm install
again to ensure that the dependencies are installed correctly.
Tailwind CSS Setup
NextUI is built on top of Tailwind CSS, so you need to install Tailwind CSS first. You can follow the official
installation guide to install Tailwind CSS. Then you need to add
the following code to your tailwind.config.js
file:
Note: If you are using pnpm and monorepo architecture, please make sure you are pointing to the ROOT
node_modules
Provider Setup
It is essential to add the NextUIProvider
at the root
of your application.
Individual Installation
NextUI is also available as individual packages. You can install each package separately. This is useful if you want to reduce the size of your CSS bundle as it will only include styles for the components you're actually using.
Note: JavaScript bundle size will not change due to tree shaking support in NextUI.
Follow the steps below to install each package separately:
Install Core Packages
Although you can install each package separately, you need to install the core packages first to ensure that all components work correctly.
Run one of the following commands in your terminal to install the core packages:
Install Component
Now, let's install the component you want to use. For example, if you want to use the Button component, you need to run one of the following commands in your terminal:
Hoisted Dependencies Setup
Note: This step is only for those who use
pnpm
to install. If you install NextUI using other package managers, you may skip this step.
If you are using pnpm, you need to add the following line to your .npmrc
file to hoist our packages to the root node_modules
.
After modifying the .npmrc
file, you need to run pnpm install
again to ensure that the dependencies are installed correctly.
Tailwind CSS Setup
TailwindCSS setup changes a bit when you use individual packages. You only need to add the
styles of the components you're using to your tailwind.config.js
file. For example, for the
Button component, you need to add the following code to your
tailwind.config.js
file:
Provider Setup
It is essential to add the NextUIProvider
at the root
of your application.
Use the Component
Now, you can use the component you installed in your application:
Version 2 is only compatible with React 18 or later. If you are using React 17 or earlier, please use version 1 of NextUI.
Framework Guides
NextUI UI is compatible with your preferred framework. We have compiled comprehensive, step-by-step tutorials for the following frameworks: