用法
ContentSearchButton组件用于打开ContentSearch模型。
<template>
<UContentSearchButton />
</template>它扩展了Button组件,因此您可以传递任何属性,如color,variant,size等。
<template>
<UContentSearchButton variant="subtle" />
</template>崩溃
使用collapsed道具显示按钮的标签,并将kbds. true转换为true。
<template>
<UContentSearchButton :collapsed="false" />
</template>Kbds
使用kbds prop在button中显示键盘键。将['meta', 'K']替换为ContentSearch组件的默认快捷方式。
<template>
<UContentSearchButton :collapsed="false" :kbds="['alt', 'O']" />
</template>API
Props
| Prop | Default | Type |
|---|---|---|
as | 'button' | anyThe element or component this component should render as when not a link. |
icon | appConfig.ui.icons.search | anyThe icon displayed in the button. Set to |
label | t('contentSearchButton.label') | stringThe label displayed in the button. |
color | 'neutral' | "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning"The color of the button. |
variant | "solid" | "outline" | "soft" | "subtle" | "ghost" | "link"The variant of the button. Defaults to 'outline' when not collapsed, 'ghost' when collapsed. | |
collapsed | true | boolean Whether the button is collapsed. |
tooltip | false | boolean | TooltipProps Display a tooltip on the button when is collapsed with the button label.
This has priority over the global |
kbds | ["meta", "k"] | (string | undefined)[] | KbdProps[]The keyboard keys to display in the button.
|
autofocus | false | true | "true" | "false" | |
disabled | boolean | |
name | string | |
type | 'button' | "reset" | "submit" | "button"The type of the button when not a link. |
activeColor | "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning" | |
activeVariant | "solid" | "outline" | "soft" | "subtle" | "ghost" | "link" | |
size | 'md' | "xs" | "sm" | "md" | "lg" | "xl" |
square | boolean Render the button with equal padding on all sides. | |
block | boolean Render the button full width. | |
loadingAuto | boolean Set loading state automatically based on the | |
avatar | AvatarPropsDisplay an avatar on the left side. | |
leading | boolean When | |
leadingIcon | anyDisplay an icon on the left side. | |
trailing | boolean When | |
trailingIcon | anyDisplay an icon on the right side. | |
loading | boolean When | |
loadingIcon | appConfig.ui.icons.loading | anyThe icon when the |
ui | { base?: SlotClass; label?: SlotClass; trailing?: SlotClass; } & { base?: SlotClass; label?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailingIcon?: SlotClass; } |
Slots
| Slot | Type |
|---|---|
leading | { ui: { base: (props?: Record<string, any> | undefined) => string; label: (props?: Record<string, any> | undefined) => string; leadingIcon: (props?: Record<string, any> | undefined) => string; leadingAvatar: (props?: Record<string, any> | undefined) => string; leadingAvatarSize: (props?: Record<string, any> | undefined) => string; trailingIcon: (props?: Record<string, any> | undefined) => string; }; } |
default | { ui: { base: (props?: Record<string, any> | undefined) => string; label: (props?: Record<string, any> | undefined) => string; leadingIcon: (props?: Record<string, any> | undefined) => string; leadingAvatar: (props?: Record<string, any> | undefined) => string; leadingAvatarSize: (props?: Record<string, any> | undefined) => string; trailingIcon: (props?: Record<string, any> | undefined) => string; }; } |
trailing | { ui: { base: (props?: Record<string, any> | undefined) => string; label: (props?: Record<string, any> | undefined) => string; leadingIcon: (props?: Record<string, any> | undefined) => string; leadingAvatar: (props?: Record<string, any> | undefined) => string; leadingAvatarSize: (props?: Record<string, any> | undefined) => string; trailingIcon: (props?: Record<string, any> | undefined) => string; }; } |
Theme
export default defineAppConfig({
ui: {
contentSearchButton: {
slots: {
base: '',
label: '',
trailing: 'hidden lg:flex items-center gap-0.5 ms-auto'
},
variants: {
collapsed: {
true: {
label: 'hidden',
trailing: 'lg:hidden'
}
}
}
}
}
})import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
contentSearchButton: {
slots: {
base: '',
label: '',
trailing: 'hidden lg:flex items-center gap-0.5 ms-auto'
},
variants: {
collapsed: {
true: {
label: 'hidden',
trailing: 'lg:hidden'
}
}
}
}
}
})
]
})