我们增强了实用程序类系统,使其更直观且易于使用。虽然 CSS 变量提供了灵活性,但编写像 text-(--ui-text-muted) 这样的类被证明很麻烦。我们引入了三项重大改进
- 默认颜色阴影 (#3916): 用于默认颜色阴影的新实用程序类,它们自动映射到我们的设计系统变量。这些阴影会自动适应您的配色方案,并且可以针对浅色和深色模式进行配置https://ui.nuxtjs.org.cn/getting-started/theme#colors
- <div class="text-(--ui-primary)">
+ <div class="text-primary">
- <div class="bg-(--ui-error)">
+ <div class="bg-error">
- 中性色实用程序 (#3629): 用于文本、背景、边框、环、分隔和轮廓颜色的新实用程序类,它们映射到我们的设计系统变量。这些实用程序支持不透明度修饰符,并自动适应您的颜色模式https://ui.nuxtjs.org.cn/getting-started/theme#neutral
- <div class="text-(--ui-text-muted)">
+ <div class="text-muted">
- <div class="border-(--ui-border)">
+ <div class="border-default">
- <div class="bg-(--ui-bg-elevated)/50">
+ <div class="bg-elevated/50">
- 动态边框半径实用程序 (#3906): 覆盖默认的 Tailwind CSS
rounded-* 实用程序以使用我们的 --ui-radius CSS 变量,使其更容易在您的应用程序中保持一致的边框半径https://ui.nuxtjs.org.cn/getting-started/theme#radius
- <div class="rounded-(--ui-radius)">
+ <div class="rounded-sm">
- <div class="rounded-[calc(var(--ui-radius)*1.5)]">
+ <div class="rounded-md">
- <div class="rounded-[calc(var(--ui-radius)*2)]">
+ <div class="rounded-lg">
这些更改完全向后兼容 - 现有的基于 CSS 变量的类将继续工作,同时为新代码提供更符合人体工程学的替代方案。
<script setup lang="ts">
import type { CheckboxGroupItem, CheckboxGroupValue } from '@nuxt/ui'
const items = ref<CheckboxGroupItem[]>(['System', 'Light', 'Dark'])
const value = ref<CheckboxGroupValue[]>(['System'])
</script>
<template>
<UCheckboxGroup v-model="value" :items="items" />
</template>
<script setup lang="ts">
import type { RadioGroupItem, RadioGroupValue } from '@nuxt/ui'
const items = ref<RadioGroupItem[]>(['System', 'Light', 'Dark'])
const value = ref<RadioGroupValue>('System')
</script>
<template>
<URadioGroup v-model="value" variant="table" :items="items" />
</template>
Vue 版本现在包含对Inertia.js的内置支持。在您的 vite.config.ts 中使用 inertia: true 选项启用它
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
inertia: true
})
]
})
这会自动将所有组件中的 RouterLink 替换为 InertiaLink,为您的 Inertia.js 应用程序提供无缝集成https://ui.nuxtjs.org.cn/getting-started/installation/vue#inertia
模块已更新为使用nuxt/module-builder@1.0.0,带来了改进的构建性能和更好的 TypeScript 支持。
在此更改之后,我们重构了组件类型的处理方式,这使得 app.config.ts 更改完全支持 HMR,而以前只在重新加载页面时才有效。
- OverlayProvider: 从
.open() 返回一个覆盖实例 (#3829) (f3098df)
此 PR 将 .open() 更改为返回一个带有 result Promise 属性的覆盖实例,而不是直接返回 Promise,从而提供了更大的灵活性
<script setup lang="ts>
const modal = useOverlay()
- const result = await modal.open({ count: count.value })
+ const instance = modal.open({ count: count.value })
+ const result = await instance.result
</script>
- App: 添加全局
portal 属性 (#3688) (29fa462) - Carousel: 添加
select 事件 (#3678) (22edfd7) - CheckboxGroup: 新组件 (#3862) (9c3d53a)
- components: 添加新的
content-top 和 content-bottom 插槽 (#3886) (1a46394) - Form: 添加
attach 属性以选择退出嵌套表单附件 (#3939) (1a0d7a3) - Form: 导出加载状态 (#3861) (fdee252)
- InputMenu/SelectMenu: 处理
resetSearchTermOnSelect (cea881a),关闭#3782 - InputNumber: 添加对
stepSnapping 和 disableWheelChange 属性的支持 (#3731) (f5e6284) - Modal/Popover/Slideover: 添加
close:prevent 事件 (#3958) (f486423) - module: 定义默认颜色阴影 (#3916) (7ac7aa9)
- module: 定义中性实用程序 (#3629) (d49e0da)
- module: 动态
rounded-* 实用程序 (#3906) (f9737c8) - OverlayProvider: 从
.open() 返回一个覆盖实例 (#3829) (f3098df) - PinInput: 添加
autofocus / autofocus-delay 属性 (0456670),关闭#3717 - RadioGroup: 添加
card 和 table 变体 (#3178) (4d138ad) - Select: 处理 items 中的
onSelect 字段 (8640831) - Table: 有条件地将类应用于
tr 和 td (#3866) (80dfa88) - Tabs: 添加
list-leading 和 list-trailing 插槽 (#3837) (3447a06) - Textarea: 添加
autoresize-delay 属性 (06414d3),关闭#3730 - Textarea: 添加
icon、loading 等属性以匹配 Input (cb193f1) - Textarea: 添加
resize-none 类与 autoresize 属性 (ffafd81) - unplugin: inertia 的路由支持 (#3845) (d059efc)
- Accordion: 将
div 用于 header 标签而不是 h3 (75e4792),关闭#3963 - Alert/Toast: 使用插槽时显示操作 (5086363),关闭#3950
- Carousel: 在移动设备上将箭头移到容器内部 (d339dcb),关闭#3813
- CommandPalette: 与其他组件对齐一致 (d25265c)
- CommandPalette: 增加输入字体大小以避免缩放 (d227a10)
- CommandPalette: 防止禁用项上的悬停背景 (ba534f1)
- components:
@nuxt/module-builder 升级后重构类型 (#3855) (39c861a) - components: 尊重 popper 内容中的
transform-origin (#3919) (01d8dc7) - ContextMenu/DropdownMenu: 处理 RTL 模式 (#3744) (1ae5cc0)
- ContextMenuContent/DropdownMenuContent: 移除不需要的
any (#3741) (97274f1) - Form: 输入和输出类型推断 (#3938) (f429498)
- Form: 提交时失去焦点 (#3796) (8e78eb1)
- InputMenu/SelectMenu: 正确调用
onSelect 事件 (#3735) (f25fed5) - InputMenu/SelectMenu: 防止选择
disabled 项 (8435a0f),关闭#3474 - InputMenu/SelectMenu: 移除
valueKey 字符串大小写 (9ca213b),关闭#3949 #3331 - InputMenu/SelectMenu: 支持任意
value (#3779) (52a97e2) - InputMenu: 在移除多个项时发出
change (9d2fed1),关闭#3756 - Link: 代理
download 属性 (#3879) (47cdc2e) - NavigationMenu: 添加
sm:w-auto 内容插槽 (abe0859),关闭#3788 - Skeleton: 改进可访问性 (#3613) (3484832)
- Stepper:
icon 和 content 插槽上的 ui 属性覆盖 (1d45980),关闭#3785 - Table: 改进
data 响应性 (#3967) (6e27304) - Table: 将 header
colspan 传递给 th (#3926) (122e8ac) - Tree: 简化可重用模板类型 (#3836) (3deed4c)
- types: 允许带有破折号的颜色标识符 (#3896) (e5a1e26)
- types: 处理
ui 属性中的 ClassValue (eea1415),关闭#3860 - types: 改进动态插槽 (#3857) (8dd9d08)
- usePortal: 调整 portal 目标解析逻辑 (#3954) (db11db6)
- vite: vitest 跳过 nuxt 导入转换 (#3925) (c31bffa)
- locale: 添加保加利亚语 (#3783) (a0c9731)
- locale: 添加哈萨克语 (#3875) (43153c4)
- locale: 添加塔吉克语 (#3850) (f42a79b)
- locale: 添加维吾尔语 (#3878) (b7fc69b)
完整更新日志: https://github.com/nuxt/ui/compare/v3.0.2...v3.1.0