Command: ui-library

Description

The ui-library command adds and installs a UI components library in an existing Next.js project. It automatically configures all dependencies, configuration files, and necessary structure for each supported library.

Syntax

bash
avangcli ui-library [library]
Copied to clipboard!

Prerequisites

  • Be in a valid Next.js project
  • Node.js 20+ installed
  • Package manager configured (npm, yarn, pnpm, bun)

Supported Libraries

  • Material UI (MUI) - Robust and complete component library
  • shadcn/ui - Accessible components built with Radix UI + Tailwind
  • HeroUI - Modern and customizable components with Tailwind

Interactive Mode

bash
avangcli ui-library
Copied to clipboard!

The CLI will show a menu to select:

  1. Material UI (mui)
  2. shadcn/ui (shadcn)
  3. HeroUI (heroui)
  4. None (none)

Options

[library]

  • Type: Positional (optional)
  • Options: mui, shadcn, heroui
  • Description: UI library to install
  • Example: avangcli ui-library shadcn

Usage Examples

Example 1: Interactive Mode

bash
avangcli ui-library
# Select from list
Copied to clipboard!

Example 2: Material UI

bash
avangcli ui-library mui
Copied to clipboard!

Example 3: shadcn/ui

bash
avangcli ui-library shadcn
Copied to clipboard!

Example 4: HeroUI

bash
avangcli ui-library heroui
Copied to clipboard!

Material UI (MUI)

What Gets Installed?

bash
šŸ“¦ Packages:
- @mui/material
- @emotion/react
- @emotion/styled
Copied to clipboard!

Automatic Configuration

AvangCLI automatically configures:

  1. Theme Provider in app/layout.tsx
  2. Emotion Cache for SSR
  3. Typography configuration

After Installation

typescript
// Use MUI components
import { Button, TextField, Card } from '@mui/material'

export default function MyComponent() {
  return (
    <Card>
      <TextField label="Name" />
      <Button variant="contained">Submit</Button>
    </Card>
  )
}
Copied to clipboard!

Theme Customization

typescript
// app/theme.ts
import { createTheme } from "@mui/material/styles"

export const theme = createTheme({
  palette: {
    primary: {
      main: "#1976d2"
    },
    secondary: {
      main: "#dc004e"
    }
  }
})
Copied to clipboard!

MUI Resources


shadcn/ui

Special Requirements

āš ļø shadcn/ui requires Tailwind CSS

If your project doesn't have Tailwind, AvangCLI will install it automatically.

What Gets Installed?

bash
šŸ“¦ Base packages:
- tailwindcss (if not installed)
- @radix-ui/react-* (depending on components)
- class-variance-authority
- clsx
- tailwind-merge

šŸ“ Files created:
- components.json
- lib/utils.ts
- components/ui/ (folder for components)
Copied to clipboard!

Automatic Configuration

AvangCLI configures:

  1. components.json - shadcn configuration
  2. lib/utils.ts - cn() utility for classes
  3. Tailwind config - Colors and CSS variables
  4. globals.css - Theme variables

After Installation

Add components one by one:

bash
# Add Button component
npx shadcn@latest add button

# Add Card component
npx shadcn@latest add card

# Add Dialog component
npx shadcn@latest add dialog

# Add multiple components
npx shadcn@latest add button card dialog input
Copied to clipboard!

Using Components

typescript
// After: npx shadcn@latest add button
import { Button } from '@/components/ui/button'

export default function MyComponent() {
  return (
    <Button variant="default">Click me</Button>
  )
}
Copied to clipboard!

Theme Customization

css
/* app/globals.css */
@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;
    /* ... more variables */
  }
}
Copied to clipboard!

shadcn/ui Advantages

āœ… Copy & Paste - Not npm packages, it's your code āœ… Customizable - Modify each component freely āœ… Accessible - Built with Radix UI (WAI-ARIA) āœ… Typed - Full TypeScript support āœ… Flexible - Use only what you need

shadcn/ui Resources


HeroUI

Special Requirements

āš ļø HeroUI requires Tailwind CSS

If you don't have Tailwind, AvangCLI will install it automatically.

What Gets Installed?

bash
šŸ“¦ Packages:
- @heroui/react
- framer-motion
- tailwindcss (if not installed)
Copied to clipboard!

Automatic Configuration

AvangCLI configures:

  1. Tailwind config - HeroUI plugin
  2. Provider - HeroUIProvider in layout
  3. Theme - Color configuration

After Installation

bash
# Add Button component
heroui add button

# Add Card component
heroui add card

# Add all components
heroui add --all
Copied to clipboard!

Using Components

typescript
import { Button, Card, Input } from '@heroui/react'

export default function MyComponent() {
  return (
    <Card>
      <Input label="Email" />
      <Button color="primary">Submit</Button>
    </Card>
  )
}
Copied to clipboard!

Theme Customization

typescript
// app/layout.tsx
import { HeroUIProvider } from '@heroui/react'

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <HeroUIProvider theme={{
          colors: {
            primary: '#0072F5',
            secondary: '#7828C8',
          }
        }}>
          {children}
        </HeroUIProvider>
      </body>
    </html>
  )
}
Copied to clipboard!

HeroUI Resources


Library Comparison

FeatureMaterial UIshadcn/uiHeroUI
Tailwind CSSāŒ Not requiredāœ… Requiredāœ… Required
Bundle SizeLarge (~100KB)Small (~20KB)Medium (~50KB)
CustomizationMediumVery HighHigh
Components60+50+40+
Accessibilityāœ… Excellentāœ… Excellentāœ… Good
AnimationsBasicCustomizableāœ… Built-in
TypeScriptāœ… Fullāœ… Fullāœ… Full
Dark Modeāœ… Yesāœ… Yesāœ… Yes
Learning curveMediumLowLow

Which One to Choose?

Choose Material UI if:

  • āœ… You want a complete and robust solution
  • āœ… You don't use Tailwind CSS
  • āœ… You need complex components (DataGrid, Autocomplete)
  • āœ… Your team knows Material Design
  • āœ… You need enterprise support (MUI X)

Ideal for: Enterprise applications, complex dashboards

Choose shadcn/ui if:

  • āœ… You use Tailwind CSS
  • āœ… You want full control over code
  • āœ… You prefer copy-paste over npm install
  • āœ… You need maximum customization
  • āœ… You value small bundle size

Ideal for: Startups, SaaS, modern applications

Choose HeroUI if:

  • āœ… You use Tailwind CSS
  • āœ… You want modern and animated components
  • āœ… You need a middle ground between MUI and shadcn
  • āœ… You value modern and clean design
  • āœ… You want built-in animations

Ideal for: Consumer-facing applications, landing pages

1. New Project with UI Library

bash
# Option 1: During init
avangcli init my-app --pm bun --tailwind --ui shadcn

# Option 2: After init
avangcli init my-app --pm bun --tailwind
cd my-app
avangcli ui-library shadcn
Copied to clipboard!

2. Existing Project

bash
# Navigate to project
cd my-existing-project

# Add UI library
avangcli ui-library mui
Copied to clipboard!

3. Change UI Library

bash
# Uninstall the previous one
npm uninstall @mui/material @emotion/react @emotion/styled

# Install the new one
avangcli ui-library shadcn
Copied to clipboard!

Automatic Validations

Tailwind Detection

bash
# shadcn/ui without Tailwind
avangcli ui-library shadcn

āš ļø shadcn/ui requires Tailwind CSS. Installing Tailwind CSS first...
āœ“ Tailwind CSS installed
āœ“ shadcn/ui configured
Copied to clipboard!

Next.js Project Detection

bash
# If you're not in a Next.js project
avangcli ui-library mui

āŒ Error: This command must be run in a Next.js project directory
Copied to clipboard!

Package Manager Detection

bash
# The CLI automatically detects:
- npm (package-lock.json)
- yarn (yarn.lock)
- pnpm (pnpm-lock.yaml)
- bun (bun.lockb)
Copied to clipboard!

Troubleshooting

Error: "Command not found: npx shadcn"

Solution:

bash
# Run with explicit npx
npx shadcn@latest add button
Copied to clipboard!

Error: "Tailwind not configured"

Solution:

bash
# Install Tailwind manually
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
Copied to clipboard!

MUI Components Don't Look Right

Cause: Missing server configuration

Solution:

typescript
// Verify you have the provider in layout.tsx
import { ThemeProvider } from "@mui/material/styles"
Copied to clipboard!

shadcn Components Have No Styles

Cause: Missing globals.css import

Solution:

typescript
// app/layout.tsx
import "./globals.css"
Copied to clipboard!

Next Steps

After installing a UI library:

  1. Explore components

    • Review official documentation
    • Test basic components
  2. Customize the theme

    • Define brand colors
    • Configure typography
  3. Create reusable components

    bash
    avangcli module shared-components --store none
    Copied to clipboard!
  4. Integrate with your modules

    typescript
    // modules/user-profile/containers/user-profile-container.tsx
    import { Card, Button } from "@/components/ui/card"
    Copied to clipboard!

Tips and Best Practices

1. Wrapper Components

typescript
// components/custom-button.tsx
import { Button } from '@mui/material'

export function CustomButton({ children, ...props }) {
  return (
    <Button
      {...props}
      sx={{ borderRadius: 2, textTransform: 'none' }}
    >
      {children}
    </Button>
  )
}
Copied to clipboard!

2. Centralized Theme

typescript
// lib/theme.ts
export const colors = {
  primary: "#0070f3",
  secondary: "#7928ca"
}
Copied to clipboard!

3. Shared Components

bash
# Create module for shared components
avangcli module ui-components --store none

# Structure:
modules/ui-components/
ā”œā”€ā”€ components/
│   ā”œā”€ā”€ custom-button.tsx
│   ā”œā”€ā”€ custom-card.tsx
│   └── custom-input.tsx
Copied to clipboard!

Last updated: 9/22/2026

Command: ui-library | AvangCLI