### Create Next.js Project with HeroUI Example (Pages Directory) Source: https://beta.heroui.com/docs/guide/introduction/frameworks/nextjs Create a new Next.js project using `create-next-app` with a pre-configured HeroUI example for the Pages Directory. This provides a quick start with HeroUI already integrated into a functional Next.js application. ```pnpm pnpm create next-app --example with-heroui my-app ``` ```npm npm create next-app --example with-heroui my-app ``` ```yarn yarn create next-app --example with-heroui my-app ``` -------------------------------- ### Install HeroUI Components via CLI (App Router & Pages Directory) Source: https://beta.heroui.com/docs/guide/introduction/frameworks/nextjs Use the HeroUI CLI to automatically add individual components or the entire `@heroui/react` library to your Next.js project. This command also manages all related dependencies, simplifying the setup process. ```bash npx heroui add button ``` ```bash npx heroui add button input ``` ```bash npx heroui add @heroui/react ``` -------------------------------- ### Install HeroUI Core Packages for Individual Setup Source: https://beta.heroui.com/docs/guide/introduction/guide/installation Before installing individual components, ensure the core HeroUI packages are installed. These foundational packages are required for all HeroUI components to operate correctly. ```pnpm pnpm add @heroui/core ``` ```npm npm install @heroui/core ``` ```yarn yarn add @heroui/core ``` ```bun bun add @heroui/core ``` -------------------------------- ### Initialize New Next.js Project with HeroUI CLI (Pages Directory) Source: https://beta.heroui.com/docs/guide/introduction/frameworks/nextjs Use the HeroUI CLI to quickly set up a new Next.js project with the Pages Directory structure, pre-configured with HeroUI. This command streamlines the initial project setup, providing a ready-to-use environment. ```bash npx heroui init ``` -------------------------------- ### Install All HeroUI Components Globally Source: https://beta.heroui.com/docs/guide/introduction/guide/installation Install the complete HeroUI library by running one of the following commands in your terminal. This method imports all components from a single package for ease of use. ```pnpm pnpm add @heroui/react ``` ```npm npm install @heroui/react ``` ```yarn yarn add @heroui/react ``` ```bun bun add @heroui/react ``` -------------------------------- ### Install HeroUI Components using CLI Source: https://beta.heroui.com/docs/guide/introduction/frameworks/vite Use the HeroUI CLI to automatically add individual or multiple components, or the entire @heroui/react library, to your project. The CLI handles dependency management, simplifying the installation process. ```bash npx heroui add button ``` ```bash npx heroui add button input ``` ```bash npx heroui add @heroui/react ``` -------------------------------- ### Manually Install HeroUI Library Dependencies Source: https://beta.heroui.com/docs/guide/introduction/frameworks/nextjs Install the core `@heroui/react` library in your Next.js project using your preferred package manager. This step is essential for manual setup and provides the foundational HeroUI components. ```pnpm pnpm add @heroui/react ``` ```npm npm install @heroui/react ``` ```yarn yarn add @heroui/react ``` ```bun bun add @heroui/react ``` -------------------------------- ### Use an Individually Installed HeroUI Component Source: https://beta.heroui.com/docs/guide/introduction/guide/installation After installing a specific HeroUI component, import and use it in your React application. This example demonstrates how to integrate the Button component into your UI. ```React import { Button } from '@heroui/button'; function MyComponent() { return ( ); } ``` -------------------------------- ### Install Specific HeroUI Components Individually Source: https://beta.heroui.com/docs/guide/introduction/guide/installation Install only the components you need, such as the Button component, to reduce your CSS bundle size. This approach allows for more granular control over your project's dependencies. ```pnpm pnpm add @heroui/button ``` ```npm npm install @heroui/button ``` ```yarn yarn add @heroui/button ``` ```bun bun add @heroui/button ``` -------------------------------- ### Install HeroUI Components via CLI in Laravel Source: https://beta.heroui.com/docs/guide/introduction/frameworks/laravel Use the HeroUI CLI to automatically add components and manage dependencies in your Laravel project. This method simplifies the installation of individual components or the entire HeroUI React library. Ensure `npx` is available in your environment. ```Bash npx heroui add button ``` ```Bash npx heroui add button input ``` ```Bash npx heroui add @heroui/react ``` ```Bash npx heroui add ``` -------------------------------- ### Install HeroUI Navbar Component Source: https://beta.heroui.com/docs/guide/introduction/components/navbar This snippet provides commands to install the HeroUI Navbar component using various package managers. This is for individual component installation; if `@heroui/react` is already globally installed, this step can be skipped. ```pnpm pnpm add @heroui/navbar ``` ```npm npm install @heroui/navbar ``` ```yarn yarn add @heroui/navbar ``` ```bun bun add @heroui/navbar ``` -------------------------------- ### Add HeroUI Components using CLI Source: https://beta.heroui.com/docs/guide/introduction/guide/installation Use the HeroUI CLI to quickly add individual components, multiple components, or the entire @heroui/react library to your project. This command automatically manages component dependencies. ```Shell npx heroui add button ``` ```Shell npx heroui add button input ``` ```Shell npx heroui add @heroui/react ``` -------------------------------- ### Install HeroUI Dependencies After Migration Source: https://beta.heroui.com/docs/guide/introduction/guide/nextui-to-heroui After running the automatic migration codemod, install the newly updated HeroUI dependencies. This step ensures all required packages are correctly installed for your migrated project. ```pnpm pnpm install ``` ```npm npm install ``` ```yarn yarn install ``` ```bun bun install ``` -------------------------------- ### Set up HeroUIProvider for Individual Component Usage Source: https://beta.heroui.com/docs/guide/introduction/guide/installation Ensure HeroUIProvider is added at the root of your application, regardless of whether you're using global or individual HeroUI installations. This provider is fundamental for component functionality. ```React import { HeroUIProvider } from '@heroui/react'; function App() { return ( {/* Your application */} ); } ``` -------------------------------- ### Set up HeroUIProvider for Global HeroUI Usage Source: https://beta.heroui.com/docs/guide/introduction/guide/installation Wrap your application's root component with HeroUIProvider. This is essential for HeroUI components to function correctly, providing necessary context and themes. ```React import { HeroUIProvider } from '@heroui/react'; function App() { return ( {/* Your application */} ); } ``` -------------------------------- ### Set up HeroUIProvider in React Application Source: https://beta.heroui.com/docs/guide/introduction/frameworks/vite Wrap your main application component with `HeroUIProvider` in `main.jsx` or `main.tsx` to enable HeroUI's context and functionality throughout your application. This is a mandatory step for HeroUI components to function correctly. ```jsx import React from 'react'; import ReactDOM from 'react-dom/client'; import App from './App.jsx'; import './index.css'; import { HeroUIProvider } from '@heroui/react'; ReactDOM.createRoot(document.getElementById('root')).render( ); ``` -------------------------------- ### Set Up HeroUI Provider in Next.js App Router Source: https://beta.heroui.com/docs/guide/introduction/frameworks/nextjs Create an `app/providers.tsx` or `app/providers.jsx` file and wrap your application's children with `HeroUIProvider`. This component enables HeroUI's context, theming, and other functionalities for your components. ```javascript 'use client'; import { HeroUIProvider } from '@heroui/react'; export function Providers({ children }) { return ( {children} ); } ``` -------------------------------- ### Install HeroUI Beta for Tailwind v4 Projects Source: https://beta.heroui.com/docs/guide/introduction/guide/tailwind-v4 Install the beta version of HeroUI, which is compatible with TailwindCSS v4. This step is crucial before proceeding with configuration updates. Use your preferred package manager. ```pnpm pnpm add @heroui/react@beta ``` ```npm npm install @heroui/react@beta ``` ```yarn yarn add @heroui/react@beta ``` ```bun bun add @heroui/react@beta ``` -------------------------------- ### Set Up HeroUI Provider in Next.js Pages Directory Source: https://beta.heroui.com/docs/guide/introduction/frameworks/nextjs Modify your `pages/_app.js` or `pages/_app.tsx` file to wrap the `Component` with `HeroUIProvider`. This ensures HeroUI's context and theming are available across all pages in your Pages Directory project, providing consistent UI. ```javascript import { HeroUIProvider } from '@heroui/react'; function MyApp({ Component, pageProps }) { return ( ); } export default MyApp; ``` -------------------------------- ### Install HeroUI in Astro Projects Source: https://beta.heroui.com/docs/guide/introduction/frameworks/astro Install the HeroUI library into your Astro project using your preferred package manager. This step adds the core HeroUI dependencies required for development. ```pnpm pnpm add @heroui/react ``` ```npm npm install @heroui/react ``` ```yarn yarn add @heroui/react ``` ```bun bun add @heroui/react ``` -------------------------------- ### Configure Tailwind CSS for HeroUI Source: https://beta.heroui.com/docs/guide/introduction/frameworks/vite Integrate HeroUI with your existing Tailwind CSS setup by extending the `content` array in your `tailwind.config.js` file. This ensures Tailwind processes HeroUI's component styles correctly. Remember to point to the root `node_modules` in monorepos. ```javascript /** @type {import('tailwindcss').Config} */ module.exports = { content: [ // ... './node_modules/@heroui/**/*.{js,ts,jsx,tsx}' ], theme: { extend: {}, }, plugins: [] } ``` -------------------------------- ### Interactively Add HeroUI Components with CLI Source: https://beta.heroui.com/docs/guide/introduction/frameworks/remix Run this command without specifying a component name to have the HeroUI CLI prompt you to select which components to add interactively, guiding you through the installation process. ```Shell npx heroui@latest add ``` -------------------------------- ### Manually Add HeroUI Dependencies to Laravel Source: https://beta.heroui.com/docs/guide/introduction/frameworks/laravel Install the core HeroUI React library manually using your preferred package manager. This step adds `@heroui/react` to your project's dependencies, preparing it for component usage. Choose the command corresponding to your package manager. ```pnpm pnpm add @heroui/react ``` ```npm npm install @heroui/react ``` ```yarn yarn add @heroui/react ``` ```bun bun add @heroui/react ``` -------------------------------- ### Import HeroUI Components in App Router Source: https://beta.heroui.com/docs/guide/introduction/frameworks/nextjs Import individual HeroUI components directly from their specific packages, rather than from `@heroui/react`. This approach allows for better tree-shaking, optimizing your bundle size by only including the components you use. ```javascript import { Button } from '@heroui/react/button'; ``` -------------------------------- ### Add HeroUI Dependencies Manually Source: https://beta.heroui.com/docs/guide/introduction/frameworks/vite Manually install the @heroui/react library in your Vite React project using your preferred package manager. This step is a prerequisite for using HeroUI components. ```pnpm pnpm add @heroui/react ``` ```npm npm install @heroui/react ``` ```yarn yarn add @heroui/react ``` ```bun bun add @heroui/react ``` -------------------------------- ### Configure pnpm Hoisted Dependencies for Individual HeroUI Packages Source: https://beta.heroui.com/docs/guide/introduction/guide/installation For pnpm users installing individual HeroUI packages, add this line to your .npmrc file. This step is crucial for correctly hoisting dependencies to the root node_modules. ```npmrc public-hoist-pattern[]=@heroui/* ``` -------------------------------- ### Install HeroUI Image Component Source: https://beta.heroui.com/docs/guide/introduction/components/image This snippet provides commands to install the HeroUI Image component using various package managers. It's an individual installation step, which can be skipped if `@heroui/react` is already installed globally in your project. ```pnpm pnpm add @heroui/image ``` ```npm npm install @heroui/image ``` ```yarn yarn add @heroui/image ``` ```bun bun add @heroui/image ``` -------------------------------- ### Set Up Tailwind CSS for HeroUI in Laravel Source: https://beta.heroui.com/docs/guide/introduction/frameworks/laravel Integrate HeroUI with your Tailwind CSS configuration by extending the `content` array in `tailwind.config.js`. This step ensures that Tailwind CSS correctly processes HeroUI's utility classes. Verify the path points to the root `node_modules` in monorepo setups. ```JavaScript /** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./node_modules/@heroui/**/*.{js,ts,jsx,tsx}" ], theme: { extend: {} }, plugins: [] } ``` -------------------------------- ### Install HeroUI DatePicker Component Source: https://beta.heroui.com/docs/guide/introduction/components/date-picker This snippet provides commands to install the `@heroui/date-picker` package using various package managers. This is for individual component installation; you may skip this step if `@heroui/react` is already installed globally. ```pnpm pnpm add @heroui/date-picker ``` ```npm npm install @heroui/date-picker ``` ```yarn yarn add @heroui/date-picker ``` ```bun bun add @heroui/date-picker ``` -------------------------------- ### Install HeroUI Project Dependencies Source: https://beta.heroui.com/docs/guide/introduction/guide/cli Installs all required project dependencies after initializing a new HeroUI project. This step is crucial for the project to function correctly and access all necessary libraries. It ensures all packages defined in the project's manifest are available. ```pnpm pnpm install ``` ```npm npm install ``` ```yarn yarn install ``` ```bun bun install ``` -------------------------------- ### Configure pnpm Hoisted Dependencies for Global HeroUI Source: https://beta.heroui.com/docs/guide/introduction/guide/installation If using pnpm for global HeroUI installation, add this line to your .npmrc file. This ensures that HeroUI packages are correctly hoisted to the root node_modules directory, resolving potential dependency issues. ```npmrc public-hoist-pattern[]=@heroui/* ``` -------------------------------- ### Configure pnpm Hoisted Dependencies for HeroUI Source: https://beta.heroui.com/docs/guide/introduction/frameworks/nextjs For pnpm users, add this line to your `.npmrc` file to ensure HeroUI packages are correctly hoisted to the root `node_modules`. After modifying the file, you must run `pnpm install` again to apply the changes. ```npmrc public-hoist-pattern[]=@heroui/* ``` -------------------------------- ### List Installed HeroUI Components with CLI Source: https://beta.heroui.com/docs/guide/introduction/guide/cli The `list` command provides a clear overview of all HeroUI components currently installed in your project. It details each component's name and version. This helps in quickly assessing your project's component inventory. ```Shell # List all installed HeroUI components heroui list # Example output Installed HeroUI Components: - Button v1.0.0 - Navbar v2.1.0 - Card v1.5.2 ``` -------------------------------- ### HeroUI CLI Init Command API Reference Source: https://beta.heroui.com/docs/guide/introduction/api-references/cli-api Details the `init` command for initializing new HeroUI projects. It specifies the available options for selecting a project template and a package manager, enabling quick project setup. ```json { "command": "init", "description": "Initialize a new HeroUI project with official templates.", "options": [ { "name": "-t, --template", "type": "string", "description": "The template to use for the new project e.g. app, laravel, pages, remix, vite" }, { "name": "-p, --package", "type": "string", "description": "The package manager to use for the new project (default: npm)" } ], "example": "heroui init -t app -p npm" } ``` -------------------------------- ### Install HeroUI Skeleton Component Source: https://beta.heroui.com/docs/guide/introduction/components/skeleton Install the `@heroui/skeleton` package using your preferred package manager. This step is optional if `@heroui/react` is already installed globally, as it often includes individual components. ```pnpm pnpm add @heroui/skeleton ``` ```npm npm install @heroui/skeleton ``` ```yarn yarn add @heroui/skeleton ``` ```bun bun add @heroui/skeleton ``` -------------------------------- ### Configure pnpm Hoisted Dependencies for HeroUI Source: https://beta.heroui.com/docs/guide/introduction/frameworks/laravel If using pnpm, configure your `.npmrc` file to hoist HeroUI packages to the root `node_modules` directory. This ensures correct dependency resolution for HeroUI components. After modification, run `pnpm install` again to apply changes. ```INI public-hoist-pattern[]=@heroui/* ``` ```Bash pnpm install ``` -------------------------------- ### Configure pnpm Hoisted Dependencies for HeroUI Source: https://beta.heroui.com/docs/guide/introduction/frameworks/vite For pnpm users, add a specific pattern to your .npmrc file to ensure HeroUI packages are correctly hoisted to the root node_modules. This is crucial for proper dependency resolution and requires running pnpm install again after modification. ```ini public-hoist-pattern[]=@heroui/* ``` -------------------------------- ### Install HeroUI Spacer Component via CLI Source: https://beta.heroui.com/docs/guide/introduction/components/spacer This snippet provides commands to install the @heroui/spacer package using various package managers. Choose the command corresponding to your preferred package manager for individual installation. ```pnpm pnpm add @heroui/spacer ``` ```npm npm install @heroui/spacer ``` ```yarn yarn add @heroui/spacer ``` ```bun bun add @heroui/spacer ``` -------------------------------- ### Integrate HeroUI Provider into App Router Root Layout Source: https://beta.heroui.com/docs/guide/introduction/frameworks/nextjs Import the `Providers` component into your root layout file (e.g., `app/layout.tsx`) and wrap your `children` with it. This ensures the HeroUI context is available throughout your entire application, enabling consistent styling and behavior. ```javascript import { Providers } from './providers'; export default function RootLayout({ children }) { return ( {children} ); } ``` -------------------------------- ### Install HeroUI Accordion Component Source: https://beta.heroui.com/docs/guide/introduction/components/accordion This snippet provides commands to install the @heroui/accordion package using various package managers. Choose the command that corresponds to your preferred package manager. ```CLI heroui add accordion ``` ```pnpm pnpm add @heroui/accordion ``` ```npm npm install @heroui/accordion ``` ```yarn yarn add @heroui/accordion ``` ```bun bun add @heroui/accordion ``` -------------------------------- ### Basic Usage of HeroUI Textarea Source: https://beta.heroui.com/docs/guide/introduction/components/textarea This example shows the basic implementation of the Textarea component. It includes a label and a placeholder to guide user input. The component is ready for use within a React functional component. ```React import { Textarea } from "@heroui/input"; function MyForm() { return (