Nuxt
Install newt/ui in a Nuxt 4 project, with the module that auto-imports the components and injects the tokens.
Choose the brand hue, the radius and the font in newt/create, and it prints a preset code. Pass that code to init and the project comes out already wearing it.
npx newtui@latest init --preset <code> --template nuxtpnpm dlx newtui@latest init --preset <code> --template nuxtyarn dlx newtui@latest init --preset <code> --template nuxtbunx newtui@latest init --preset <code> --template nuxtdeno run -A npm:newtui@latest init --preset <code> --template nuxtvlx newtui@latest init --preset <code> --template nuxtvp dlx newtui@latest init --preset <code> --template nuxtnubx newtui@latest init --preset <code> --template nuxtnlx newtui@latest init --preset <code> --template nuxtupx newtui@latest init --preset <code> --template nuxt- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
npx newtui@latest add buttonnpx shadcn@latest add @newtui/buttonnpx shadcn-vue@latest add @newtui/buttonpnpm dlx newtui@latest add buttonpnpm dlx shadcn@latest add @newtui/buttonpnpm dlx shadcn-vue@latest add @newtui/buttonyarn dlx newtui@latest add buttonyarn dlx shadcn@latest add @newtui/buttonyarn dlx shadcn-vue@latest add @newtui/buttonbunx newtui@latest add buttonbunx shadcn@latest add @newtui/buttonbunx shadcn-vue@latest add @newtui/buttondeno run -A npm:newtui@latest add buttondeno run -A npm:shadcn@latest add @newtui/buttondeno run -A npm:shadcn-vue@latest add @newtui/buttonvlx newtui@latest add buttonvlx shadcn@latest add @newtui/buttonvlx shadcn-vue@latest add @newtui/buttonvp dlx newtui@latest add buttonvp dlx shadcn@latest add @newtui/buttonvp dlx shadcn-vue@latest add @newtui/buttonnubx newtui@latest add buttonnubx shadcn@latest add @newtui/buttonnubx shadcn-vue@latest add @newtui/buttonnlx newtui@latest add buttonnlx shadcn@latest add @newtui/buttonnlx shadcn-vue@latest add @newtui/buttonupx newtui@latest add buttonupx shadcn@latest add @newtui/buttonupx shadcn-vue@latest add @newtui/button- newtui
- shadcn
- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
The shadcn CLI needs the @newtui registry in your components.json. Set it up.
One command creates the project and wires the tokens into it. --template exists for Next.js, both Vite flavours and Nuxt; everywhere else init runs inside a project you already made.
npx newtui@latest init --template nuxtpnpm dlx newtui@latest init --template nuxtyarn dlx newtui@latest init --template nuxtbunx newtui@latest init --template nuxtdeno run -A npm:newtui@latest init --template nuxtvlx newtui@latest init --template nuxtvp dlx newtui@latest init --template nuxtnubx newtui@latest init --template nuxtnlx newtui@latest init --template nuxtupx newtui@latest init --template nuxt- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
npx newtui@latest add buttonnpx shadcn@latest add @newtui/buttonnpx shadcn-vue@latest add @newtui/buttonpnpm dlx newtui@latest add buttonpnpm dlx shadcn@latest add @newtui/buttonpnpm dlx shadcn-vue@latest add @newtui/buttonyarn dlx newtui@latest add buttonyarn dlx shadcn@latest add @newtui/buttonyarn dlx shadcn-vue@latest add @newtui/buttonbunx newtui@latest add buttonbunx shadcn@latest add @newtui/buttonbunx shadcn-vue@latest add @newtui/buttondeno run -A npm:newtui@latest add buttondeno run -A npm:shadcn@latest add @newtui/buttondeno run -A npm:shadcn-vue@latest add @newtui/buttonvlx newtui@latest add buttonvlx shadcn@latest add @newtui/buttonvlx shadcn-vue@latest add @newtui/buttonvp dlx newtui@latest add buttonvp dlx shadcn@latest add @newtui/buttonvp dlx shadcn-vue@latest add @newtui/buttonnubx newtui@latest add buttonnubx shadcn@latest add @newtui/buttonnubx shadcn-vue@latest add @newtui/buttonnlx newtui@latest add buttonnlx shadcn@latest add @newtui/buttonnlx shadcn-vue@latest add @newtui/buttonupx newtui@latest add buttonupx shadcn@latest add @newtui/buttonupx shadcn-vue@latest add @newtui/button- newtui
- shadcn
- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
The shadcn CLI needs the @newtui registry in your components.json. Set it up.
Create the app
npm create nuxt@latest my-appAdd Tailwind
npm install tailwindcss @tailwindcss/viteimport tailwindcss from "@tailwindcss/vite"
export default defineNuxtConfig({
css: ["~/assets/css/tailwind.css"],
vite: { plugins: [tailwindcss()] },
})@import "tailwindcss";Run init
npx newtui@latest init --framework vue --bundler nuxtpnpm dlx newtui@latest init --framework vue --bundler nuxtyarn dlx newtui@latest init --framework vue --bundler nuxtbunx newtui@latest init --framework vue --bundler nuxtdeno run -A npm:newtui@latest init --framework vue --bundler nuxtvlx newtui@latest init --framework vue --bundler nuxtvp dlx newtui@latest init --framework vue --bundler nuxtnubx newtui@latest init --framework vue --bundler nuxtnlx newtui@latest init --framework vue --bundler nuxtupx newtui@latest init --framework vue --bundler nuxt- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
init guesses the bundler from a nuxt.config, so the flags are only needed
when it guesses wrong.
In a Nuxt project, init also adds a components option to nuxt.config.ts.
Component barrels gives the reason.
Add a component
npx newtui@latest add buttonnpx shadcn@latest add @newtui/buttonnpx shadcn-vue@latest add @newtui/buttonpnpm dlx newtui@latest add buttonpnpm dlx shadcn@latest add @newtui/buttonpnpm dlx shadcn-vue@latest add @newtui/buttonyarn dlx newtui@latest add buttonyarn dlx shadcn@latest add @newtui/buttonyarn dlx shadcn-vue@latest add @newtui/buttonbunx newtui@latest add buttonbunx shadcn@latest add @newtui/buttonbunx shadcn-vue@latest add @newtui/buttondeno run -A npm:newtui@latest add buttondeno run -A npm:shadcn@latest add @newtui/buttondeno run -A npm:shadcn-vue@latest add @newtui/buttonvlx newtui@latest add buttonvlx shadcn@latest add @newtui/buttonvlx shadcn-vue@latest add @newtui/buttonvp dlx newtui@latest add buttonvp dlx shadcn@latest add @newtui/buttonvp dlx shadcn-vue@latest add @newtui/buttonnubx newtui@latest add buttonnubx shadcn@latest add @newtui/buttonnubx shadcn-vue@latest add @newtui/buttonnlx newtui@latest add buttonnlx shadcn@latest add @newtui/buttonnlx shadcn-vue@latest add @newtui/buttonupx newtui@latest add buttonupx shadcn@latest add @newtui/buttonupx shadcn-vue@latest add @newtui/button- newtui
- shadcn
- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
The shadcn CLI needs the @newtui registry in your components.json. Set it up.
<script setup lang="ts">
import { Button } from "@/components/ui/button"
</script>
<template>
<Button variant="primary">Send</Button>
</template>Put .newt-root on the wrapper in app.vue.
Component barrels
add writes each Vue component as a folder: the .vue files and an index.ts
barrel. Nuxt reads every file under components/ as a component. It names an
index file after its folder, so tabs/index.ts and tabs/Tabs.vue both
resolve to UiTabs. Nuxt then prints one warning for each folder:
WARN [NUXT_B3011] Two component files resolving to the same name UiTabs:
- ~/components/ui/tabs/index.ts
- ~/components/ui/tabs/Tabs.vue
Your code imports from the barrel, so Nuxt does not need to register it. init
adds this option to nuxt.config.ts. It keeps the barrels out of the scan:
export default defineNuxtConfig({
components: [
{ path: "~/components/islands", island: true },
{ path: "~/components/global", global: true },
{ path: "~/components", ignore: ["ui/**/index.ts"] },
],
})
The first two entries are the directories Nuxt scans by default. A components
array replaces those defaults, so the option names them again.
- The pattern follows the
uialias incomponents.json. The alias@/components/newt/uigivesnewt/ui/**/index.ts. - A project without TypeScript gets
index.jsin the pattern. - If the
uialias points outsidecomponents/, Nuxt does not scan it.initthen changes nothing. initedits the file only if it has one multi-linedefineNuxtConfig({call, nocomponentsoption and no top-level spread such as...sharedConfig. If it does not,initprints the lines to add.- A spread object can set
componentsand replace the option. If yours does, add the ignore there. - If your config already sets
components, addignore: ["ui/**/index.ts"]to the entry for~/components. - If you ran
initbefore it wrote this option, add the option yourself.
The module
@newtui/nuxt saves you the imports. It registers your components/ui
directory with Nuxt, so Button.vue is available as <Button /> anywhere
without the directory name in front of it, and it prepends the token stylesheet
to your CSS so the variables exist before your own styles run. It needs Nuxt 4.
The module registers components/ui before Nuxt scans components/. It reads
only the .vue files, so the barrels cause no warning with the module either.
npm install @newtui/nuxtpnpm add @newtui/nuxtyarn add @newtui/nuxtbun add @newtui/nuxtdeno add npm:@newtui/nuxtvlt install @newtui/nuxtvp add @newtui/nuxtnub add @newtui/nuxtni @newtui/nuxtupm add @newtui/nuxt- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
export default defineNuxtConfig({
modules: ["@newtui/nuxt"],
newt: {
prefix: "", // "Newt" gives you <NewtButton />
componentDir: "components",
css: true, // false if you already ship the tokens
},
})
All three options are optional. prefix namespaces the auto-imported names if a
bare <Button /> would collide with something you already have,
componentDir points at your components directory relative to the Nuxt source
directory, and css: false turns the injected tokens off when your own CSS
entry already carries them.
What init writes
components.json the config, shared with shadcn
app/assets/css/tailwind.css the --newt-* token block
app/lib/utils.ts cn()
nuxt.config.ts the components option
app/components/ui/button/Button.vue add button
app/components/ui/button/index.ts
See Dark mode for the theme toggle, and RTL if the app has to run right to left.
A project that also uses Nuxt UI can make its components follow the same tokens with the Nuxt UI theme.