本指南将帮助您在 Vue 或 Nuxt 应用程序中安装和设置 Inspira UI 组件。
注意: 如果您正在使用 shadcn-vue
,则可以跳过安装步骤并仅安装以下库。
npm install @vueuse/core motion-v
pnpm install @vueuse/core motion-v
bun add @vueuse/core motion-v
yarn add @vueuse/core motion-v
按照本指南在 Vue 或 Nuxt 上设置 motion-v
。
首先,请按照本指南安装 tailwindcss
。
安装 tailwindcss 库和实用工具。
npm install -D clsx tailwind-merge class-variance-authority tw-animate-css
pnpm install -D clsx tailwind-merge class-variance-authority tw-animate-css
bun add -d clsx tailwind-merge class-variance-authority tw-animate-css
yarn add --dev clsx tailwind-merge class-variance-authority tw-animate-css
安装 VueUse 和其他支持库。
npm install @vueuse/core motion-v
pnpm install @vueuse/core motion-v
bun add @vueuse/core motion-v
yarn add @vueuse/core motion-v
按照本指南在 Vue 或 Nuxt 上设置 motion-v
。
将以下代码添加到您的 main.css
文件中,这将设置组件所需的变量:
@import "tailwindcss";
@import "tw-animate-css";
@custom-variant dark (&:is(.dark *));
:root {
--card: oklch(1 0 0);
--card-foreground: oklch(0.141 0.005 285.823);
--popover: oklch(1 0 0);
--popover-foreground: oklch(0.141 0.005 285.823);
--primary: oklch(0.21 0.006 285.885);
--primary-foreground: oklch(0.985 0 0);
--secondary: oklch(0.967 0.001 286.375);
--secondary-foreground: oklch(0.21 0.006 285.885);
--muted: oklch(0.967 0.001 286.375);
--muted-foreground: oklch(0.552 0.016 285.938);
--accent: oklch(0.967 0.001 286.375);
--accent-foreground: oklch(0.21 0.006 285.885);
--destructive: oklch(0.577 0.245 27.325);
--destructive-foreground: oklch(0.577 0.245 27.325);
--border: oklch(0.92 0.004 286.32);
--input: oklch(0.92 0.004 286.32);
--ring: oklch(0.705 0.015 286.067);
--radius: 0.625rem;
--background: oklch(1 0 0);
--foreground: oklch(0.141 0.005 285.823);
}
.dark {
--background: oklch(0.141 0.005 285.823);
--foreground: oklch(0.985 0 0);
--card: oklch(0.141 0.005 285.823);
--card-foreground: oklch(0.985 0 0);
--popover: oklch(0.141 0.005 285.823);
--popover-foreground: oklch(0.985 0 0);
--primary: oklch(0.985 0 0);
--primary-foreground: oklch(0.21 0.006 285.885);
--secondary: oklch(0.274 0.006 286.033);
--secondary-foreground: oklch(0.985 0 0);
--muted: oklch(0.274 0.006 286.033);
--muted-foreground: oklch(0.705 0.015 286.067);
--accent: oklch(0.274 0.006 286.033);
--accent-foreground: oklch(0.985 0 0);
--destructive: oklch(0.396 0.141 25.723);
--destructive-foreground: oklch(0.637 0.237 25.331);
--border: oklch(0.274 0.006 286.033);
--input: oklch(0.274 0.006 286.033);
--ring: oklch(0.442 0.017 285.786);
}
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-popover: var(--popover);
--color-popover-foreground: var(--popover-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-destructive-foreground: var(--destructive-foreground);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
}
@layer base {
* {
@apply border-border outline-ring/50;
}
body {
@apply bg-background text-foreground;
}
}
html {
color-scheme: light dark;
}
html.dark {
color-scheme: dark;
}
html.light {
color-scheme: light;
}
将以下实用工具添加到 lib/utils.ts
utils.ts
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export type ObjectValues<T> = T[keyof T];
太棒了!您的项目现已配置为使用 Inspira UI。
各种 Inspira UI 组件和演示都使用了带有 Iconify 图标的 <Icon>
组件。虽然可选,但我们建议您安装它以获得最佳体验。
要为您的 Vue.js 或 Nuxt.js 项目添加图标支持,请遵循 Iconify Vue 指南。
现在,您可以开始在项目中使用 Inspira UI 组件了。选择所需的组件,复制代码,然后将其集成到您的应用程序中。