mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
241 lines
5.1 KiB
Markdown
241 lines
5.1 KiB
Markdown
---
|
|
title: Installation
|
|
description: 'Learn how to install and configure Nuxt UI in your Nuxt application.'
|
|
framework: nuxt
|
|
module: ui
|
|
---
|
|
|
|
::callout{to="/getting-started/installation/vue" icon="i-logos-vue" class="hidden"}
|
|
Looking for the **Vue** version?
|
|
::
|
|
|
|
## Setup
|
|
|
|
### Add to a Nuxt project
|
|
|
|
::steps{level="4"}
|
|
|
|
#### Install the Nuxt UI v3 alpha package
|
|
|
|
::code-group{sync="pm"}
|
|
|
|
```bash [pnpm]
|
|
pnpm add @nuxt/ui@next
|
|
```
|
|
|
|
```bash [yarn]
|
|
yarn add @nuxt/ui@next
|
|
```
|
|
|
|
```bash [npm]
|
|
npm install @nuxt/ui@next
|
|
```
|
|
|
|
```bash [bun]
|
|
bun add @nuxt/ui@next
|
|
```
|
|
|
|
::
|
|
|
|
::warning
|
|
If you're using **pnpm**, ensure that you either set [`shamefully-hoist=true`](https://pnpm.io/npmrc#shamefully-hoist) in your `.npmrc` file or install `tailwindcss@next` in your project's root directory.
|
|
::
|
|
|
|
#### Add the Nuxt UI module in your `nuxt.config.ts`{lang="ts-type"}
|
|
|
|
```ts [nuxt.config.ts]
|
|
export default defineNuxtConfig({
|
|
modules: ['@nuxt/ui']
|
|
})
|
|
```
|
|
|
|
#### Import Tailwind CSS and Nuxt UI in your CSS
|
|
|
|
```css [assets/css/main.css]
|
|
@import "tailwindcss";
|
|
@import "@nuxt/ui";
|
|
```
|
|
|
|
::tip
|
|
Use the `css` property in your `nuxt.config.ts` to import your CSS file.
|
|
|
|
```ts [nuxt.config.ts]
|
|
export default defineNuxtConfig({
|
|
modules: ['@nuxt/ui'],
|
|
css: ['~/assets/css/main.css']
|
|
})
|
|
```
|
|
::
|
|
|
|
::callout{icon="i-simple-icons-visualstudiocode"}
|
|
It's recommended to install the [Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss) extension for VSCode and add the following settings:
|
|
|
|
```json [settings.json]
|
|
"files.associations": {
|
|
"*.css": "tailwindcss"
|
|
},
|
|
"editor.quickSuggestions": {
|
|
"strings": "on"
|
|
}
|
|
```
|
|
|
|
::
|
|
|
|
#### Wrap your app with App component
|
|
|
|
```vue [app.vue]
|
|
<template>
|
|
<UApp>
|
|
<NuxtPage />
|
|
</UApp>
|
|
</template>
|
|
```
|
|
|
|
::note{to="/components/app"}
|
|
The `App` component provides global configurations and is required for **Toast** and **Tooltip** components to work.
|
|
::
|
|
|
|
::
|
|
|
|
### Use our Nuxt Starter
|
|
|
|
Start your project with a Nuxt template with Nuxt UI v3 pre-configured by using our [Nuxt UI Starter](https://github.com/nuxt/starter/tree/ui3).
|
|
|
|
Create a new project locally by running the following command:
|
|
|
|
```bash [Terminal]
|
|
npx nuxi@latest init -t ui3 <my-app>
|
|
```
|
|
|
|
::note
|
|
The `<my-app>` argument is the name of the directory where the project will be created, replace it with your project name.
|
|
::
|
|
|
|
Once the installation is complete, navigate into your project and start the development server:
|
|
|
|
```bash [Terminal]
|
|
cd <my-app>
|
|
npm run dev
|
|
```
|
|
|
|
## Options
|
|
|
|
You can customize Nuxt UI by providing options in your `nuxt.config.ts`.
|
|
|
|
### `prefix`
|
|
|
|
Use the `prefix` option to change the prefix of the components.
|
|
|
|
- Default: `U`{lang="ts-type"}
|
|
|
|
```ts [nuxt.config.ts]
|
|
export default defineNuxtConfig({
|
|
modules: ['@nuxt/ui'],
|
|
ui: {
|
|
prefix: 'Nuxt'
|
|
}
|
|
})
|
|
```
|
|
|
|
### `fonts`
|
|
|
|
Use the `fonts` option to enable or disable the [`@nuxt/fonts`](https://github.com/nuxt/fonts) module.
|
|
|
|
- Default: `true`{lang="ts-type"}
|
|
|
|
```ts [nuxt.config.ts]
|
|
export default defineNuxtConfig({
|
|
modules: ['@nuxt/ui'],
|
|
ui: {
|
|
fonts: false
|
|
}
|
|
})
|
|
```
|
|
|
|
### `colorMode`
|
|
|
|
Use the `colorMode` option to enable or disable the [`@nuxt/color-mode`](https://github.com/nuxt-modules/color-mode) module.
|
|
|
|
- Default: `true`{lang="ts-type"}
|
|
|
|
```ts [nuxt.config.ts]
|
|
export default defineNuxtConfig({
|
|
modules: ['@nuxt/ui'],
|
|
ui: {
|
|
colorMode: false
|
|
}
|
|
})
|
|
```
|
|
|
|
### `theme.colors`
|
|
|
|
Use the `theme.colors` option to define the dynamic color aliases used to generate components theme.
|
|
|
|
- Default: `['primary', 'secondary', 'success', 'info', 'warning', 'error']`{lang="ts-type" class="inline"}
|
|
|
|
```ts [nuxt.config.ts]
|
|
export default defineNuxtConfig({
|
|
modules: ['@nuxt/ui'],
|
|
ui: {
|
|
theme: {
|
|
colors: ['primary', 'error']
|
|
}
|
|
}
|
|
})
|
|
```
|
|
|
|
::tip{to="/getting-started/theme#colors"}
|
|
Learn more about color customization and theming in the Theme section.
|
|
::
|
|
|
|
### `theme.transitions`
|
|
|
|
Use the `theme.transitions` option to enable or disable transitions on components.
|
|
|
|
- Default: `true`{lang="ts-type"}
|
|
|
|
```ts [nuxt.config.ts]
|
|
export default defineNuxtConfig({
|
|
modules: ['@nuxt/ui'],
|
|
ui: {
|
|
theme: {
|
|
transitions: false
|
|
}
|
|
}
|
|
})
|
|
```
|
|
|
|
::note
|
|
This option adds the `transition-colors` class on components with hover or active states.
|
|
::
|
|
|
|
## Continuous Releases
|
|
|
|
Nuxt UI v3 uses [pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new) for continuous preview releases, providing developers with instant access to the latest features and bug fixes without waiting for official releases.
|
|
|
|
Preview releases are automatically generated for every commit to the `v3` branch and pull requests targeting the `v3` branch. To use it into your project, use the installation command below by replacing `5385f84` with any commit hash or pull request number.
|
|
|
|
::code-group{sync="pm"}
|
|
|
|
```bash [pnpm]
|
|
pnpm add https://pkg.pr.new/@nuxt/ui@5385f84
|
|
```
|
|
|
|
```bash [yarn]
|
|
yarn add https://pkg.pr.new/@nuxt/ui@5385f84
|
|
```
|
|
|
|
```bash [npm]
|
|
npm install https://pkg.pr.new/@nuxt/ui@5385f84
|
|
```
|
|
|
|
```bash [bun]
|
|
bun add https://pkg.pr.new/@nuxt/ui@5385f84
|
|
```
|
|
|
|
::
|
|
|
|
::note
|
|
**pkg.pr.new** will automatically comment on PRs with the installation URL, making it easy to test changes.
|
|
::
|