🌑

帮帮技术站

nextjs创建

创建项目

1
2
3
4
5
6
7
8
9
10
PS D:\workspace-nextjs> npx create-next-app@latest
√ What is your project named? ... simple-app
√ Would you like to use TypeScript? ... / Yes
√ Would you like to use ESLint? ... / Yes
√ Would you like to use Tailwind CSS? ... / Yes
√ Would you like to use `src/` directory? ... / Yes
√ Would you like to use App Router? (recommended) ... No
√ Would you like to customize the default import alias (@/*)? ... / Yes
√ What import alias would you like configured? ... @/*
Using npm.

新增nextui 不要使用pnpm

1
2
3
PS D:\workspace-nextjs> cd .\simple-app\
PS D:\workspace-nextjs\simple-app> npm i @nextui-org/react framer-motion

配置 tailwind.config.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import type { Config } from 'tailwindcss'
const { nextui } = require("@nextui-org/react");

const config: Config = {
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
"./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
'gradient-conic':
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
},
},
darkMode: "class",
plugins: [nextui()],
}
export default config

_app.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
import '@/styles/globals.css'
import type { AppProps } from 'next/app'
import { NextUIProvider } from "@nextui-org/react";

export default function App({ Component, pageProps }: AppProps) {
return (
// Use at the root of our app
<NextUIProvider>
<Component {...pageProps} />
</NextUIProvider>
);
}

run app idnex.tsx

1
2
3
4
import { Button } from "@nextui-org/react";

<Button>Button Begin</Button>

— Dec 10, 2023

Search