Usage
The ContentSearchButton component is used to open the ContentSearch modal.
<template>
<PContentSearchButton />
</template>
It extends the Button component, so you can pass any property such as color, variant, size, etc.
<template>
<PContentSearchButton variant="subtle" />
</template>
color="neutral" and variant="outline" when not collapsed, variant="ghost" when collapsed.Collapsed
Use the collapsed prop to show the button's label and kbds. Defaults to true.
<template>
<PContentSearchButton :collapsed="false" />
</template>
Kbds
Use the kbds prop to display keyboard keys in the button. Defaults to ['meta', 'K'] to match the default shortcut of the ContentSearch component.
<template>
<PContentSearchButton :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.pohon.icons.search | string | objectThe icon displayed in the button. |
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 | PTooltipProps Display a tooltip on the button when is collapsed with the button label.
This has priority over the global
|
kbds | ["meta", "k"] | (string | undefined)[] | PKbdProps[]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' | "md" | "xs" | "sm" | "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 | PAvatarPropsDisplay an avatar on the left side.
| |
leading | boolean When | |
leadingIcon | string | objectDisplay an icon on the left side. | |
trailing | boolean When | |
trailingIcon | string | objectDisplay an icon on the right side. | |
loading | boolean When | |
loadingIcon | appConfig.pohon.icons.loading | string | objectThe icon when the |
pohon | { base?: ClassValue; label?: ClassValue; trailing?: ClassValue; } & { base?: ClassValue; label?: ClassValue; leadingIcon?: ClassValue; leadingAvatar?: ClassValue; leadingAvatarSize?: ClassValue; trailingIcon?: ClassValue; }
|
Slots
| Slot | Type |
|---|---|
leading | { pohon: { 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 | { pohon: { 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 | { pohon: { 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
Below is the theme configuration skeleton for the PContentSearchButton. Since the component is provided unstyled by default, you will need to fill in these values to apply your own custom look and feel. If you prefer to use our pre-built, opinionated styling, you can instead use our UnoCSS preset, this docs is using it as well.
export default defineAppConfig({
pohon: {
contentSearchButton: {
slots: {
base: '',
label: '',
trailing: ''
},
variants: {
collapsed: {
true: {
label: '',
trailing: ''
}
}
}
}
}
};
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pohon from 'pohon-ui/vite'
export default defineAppConfig({
pohon: {
contentSearchButton: {
slots: {
base: '',
label: '',
trailing: ''
},
variants: {
collapsed: {
true: {
label: '',
trailing: ''
}
}
}
}
}
};