CLI
Project setup
What the CLI sets up in Next.js, Vite and Astro projects so installed code builds — the @/ alias, Tailwind CSS v4 and React in Astro — and how monorepos work.
MotionUIKit code imports with the @/ alias, is styled with Tailwind CSS v4, and is written in React. init, and every add after it, check that your project supports all three and set up what is missing. It prints every file it changes, and add --dry-run shows the setup it would do without doing it.
These checks run in React projects on Next.js, Vite and Astro. Other setups are left as they are.
| Setup | Next.js | Vite | Astro |
|---|---|---|---|
@/ alias | paths in tsconfig/jsconfig | paths + resolve.alias in vite.config | paths in tsconfig/jsconfig |
| Tailwind CSS v4 | PostCSS + global stylesheet | PostCSS + global stylesheet | PostCSS + global stylesheet |
| React | built in | built in | @astrojs/react, added for you |
Where files go
Files go to the folder your project keeps its code in:
- a project with a
src/folder: undersrc/; - an Astro project: under the folder its
srcDirsetting names (srcby default;srcDir: './'means the project root); - otherwise: the project root.
HTML projects are the exception. Each section is one page, installed as sections/<name>.html at the project root, next to your index.html, even when the project has a src/ folder. For example, add arcline writes sections/arcline.html.
An HTML section's images and videos go to assets/motionuikit/ (inside src/ if your project has one), and the page links to them with relative paths such as ../assets/motionuikit/images/hw-boat.webp. So the page shows them when you open it straight from its folder, with no server set up.
The CLI never creates a src/ folder in a project that doesn't use one.
The @/ alias
Every installed file imports other installed files with @/, for example @/components/motionuikit/sections/arcline/navbar. If your project can't resolve @/, the CLI asks:
? This project can't resolve "@/" imports, which every MotionUIKit file uses. Set it up? (edits jsconfig.json and vite.config.js)Yes adds the alias, pointing at your code folder:
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
}
}In Vite, it also adds the alias to vite.config, because Vite doesn't read paths by default:
export default defineConfig({
resolve: {
alias: {
'@': '/src'
}
},
plugins: [react()]
})A vite.config the CLI can't safely edit (no plain defineConfig({ … }), or a resolve section already there) is left alone, and the CLI prints the lines to add.
No changes nothing in your project. Instead, "importStyle": "relative" is saved in motionuikit.config.json, and every add rewrites the imports to relative paths: in arcline/hero-section.tsx, @/components/motionuikit/sections/arcline/navbar becomes ./navbar. If you set up @/ later, remove importStyle from the config.
Without a terminal, init --yes (or --alias) sets the alias up, and init --no-alias uses relative imports.
Tailwind CSS v4
MotionUIKit is styled with Tailwind CSS v4. If your project doesn't have it, the CLI asks to set it up with PostCSS:
- installs
tailwindcss,@tailwindcss/postcssandpostcss; - adds
@tailwindcss/postcssto your PostCSS config, or createspostcss.config.mjs; - adds
@import "tailwindcss";as the first line of your global stylesheet.
const config = {
plugins: {
'@tailwindcss/postcss': {}
}
}
export default configAn existing PostCSS config keeps its other plugins. The global stylesheet is the one your app loads: the CSS imported by your Vite entry (main.jsx) or by Next.js's app/layout, else src/index.css, app/globals.css and the other usual places.
Without a terminal, Tailwind is set up without asking. To turn it down, answer no or run init --no-tailwind: "tailwind": false is saved in the config, and the CLI won't offer it again.
Already on Tailwind v4? Nothing changes. That includes projects using the @tailwindcss/vite plugin. If Tailwind is installed but your stylesheet doesn't import it, the CLI only adds the @import line.
On Tailwind v3? The CLI upgrades it to v4. It replaces the @tailwind base;, @tailwind components; and @tailwind utilities; lines with @import "tailwindcss";, keeps your tailwind.config.js working with @config, and switches the PostCSS plugin:
@import 'tailwindcss';
@config '../tailwind.config.js';Check your project after the upgrade: some v3 class names changed in v4. See Tailwind's upgrade guide.
Sections and Tailwind
Each section ships its own stylesheet, index.css, with its colors and fonts. There are two kinds:
-
Built by your Tailwind. The stylesheet holds only the section's own colors, fonts and styles, and your project's Tailwind builds its classes, so the whole site shares one Tailwind build. The CLI lists every such section in
motionuikit.css, next to your global stylesheet (for exampleapp/motionuikit.cssbesideapp/globals.css), and imports that file once from your global stylesheet:app/globals.css @import 'tailwindcss'; @import './motionuikit.css';app/motionuikit.css /* MotionUIKit sections: one import per installed section, kept up to date by the motionuikit CLI */ @import '../components/motionuikit/sections/arcline/index.css';removetakes the section's line out again, and deletesmotionuikit.cssand its import when no section is left. If the CLI can't find your global stylesheet, it prints the line to add. -
Built on its own. The stylesheet imports Tailwind's theme and utilities itself, and the section's code imports it. The CLI adds nothing to your stylesheets for these.
Either way, Tailwind v4 has to be running in your project.
Astro
Astro projects get the same @/ alias and Tailwind setup, with three differences:
- React. Astro shows React components only through its React integration. If it's missing, the CLI runs Astro's own command,
astro add react --yes, which installs@astrojs/react,reactandreact-dom, and addsreact()toastro.config. - The global stylesheet. Astro projects don't have one by default, so the CLI creates
src/styles/global.cssand imports it in your layout (src/layouts/Layout.astro). Without a layout, it prints the line to add to your pages. - The import line is
@import "tailwindcss/index.css";, because Astro's build with PostCSS can't read the shorter@import "tailwindcss";. It's the same file.
Use a section in an Astro page with a client: directive, so its animations run in the browser:
---
import '@/styles/global.css'
import Layout from '@/layouts/Layout.astro'
import Arcline from '@/components/motionuikit/sections/arcline'
---
<Layout>
<Arcline client:load />
</Layout>Keep import '@/styles/global.css' above every component and section import, so the sections' own styles load after it. See Troubleshooting.
JavaScript projects
MotionUIKit code is written in TypeScript. In a project with "typescript": false (answer no to the TypeScript question), each .tsx and .ts file is converted to .jsx and .js as it's installed. Types are removed; the code is otherwise the same. Blank lines may remain where types were.
Monorepos
In a workspace (pnpm, npm, yarn or bun workspaces, Turborepo, Nx), run the CLI inside an app, for example apps/web. Run at the workspace root, it asks which app you mean; without a terminal, it stops and lists --cwd for each app.
Each app has its own motionuikit.config.json and .env, so apps with different settings (a TypeScript app and a JavaScript app, say) can live in one workspace.
A shared packages/ui
To share components between apps, run init --monorepo in an app:
npx motionuikit@latest init --monorepoIt uses packages/ui (creating it as @workspace/ui if it doesn't exist, or reusing yours under its own name) and wires the app to it:
- the package gets a
package.jsonwith exports,paths, and its ownmotionuikit.config.json; - the app gets the package as a dependency, a
pathsentry for it, and an@sourceline in its stylesheet so Tailwind finds the package's classes; - the app's aliases point into the package:
@workspace/ui/components/motionuikit/ui/….
After that, add from the app puts components in packages/ui and sections in the app. add run inside packages/ui puts everything in the package. npm packages are installed where the files that use them land.
Some steps are printed for you to do, not done for you: running your package manager's install, and adding transpilePackages: ['@workspace/ui'] to next.config in Next.js.