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. |
color | 'neutral' | "neutral" | "primary" | "secondary" | "success" | "info" | "warning" | "error"The color of the button. |
kbds | ["meta", "k"] | string[] | PKbdProps[]The keyboard keys to display in the button.
|
icon | appConfig.pohon.icons.search | string | objectThe icon displayed in the button. |
label | t('contentSearchButton.label') | stringThe label displayed in the button. |
variant | "solid" | "outline" | "soft" | "subtle" | "ghost" | "link"The variant of the button. Defaults to 'outline' when not collapsed, 'ghost' when collapsed. | |
autofocus | false | true | "true" | "false" | |
name | string | |
type | 'button' | "button" | "submit" | "reset"The type of the button when not a link. |
activeColor | "neutral" | "primary" | "secondary" | "success" | "info" | "warning" | "error" | |
activeVariant | "solid" | "outline" | "soft" | "subtle" | "ghost" | "link" | |
size | 'md' | "md" | "xs" | "sm" | "lg" | "xl" |
avatar | PAvatarPropsDisplay an avatar on the left side.
| |
leadingIcon | string | objectDisplay an icon on the left side. | |
trailingIcon | string | objectDisplay an icon on the right side. | |
loadingIcon | appConfig.pohon.icons.loading | string | objectThe icon when the |
collapsed | true | booleanWhether the button is collapsed. |
tooltip | false | booleanDisplay a tooltip on the button when is collapsed with the button label.
This has priority over the global |
disabled | boolean | |
square | booleanRender the button with equal padding on all sides. | |
block | booleanRender the button full width. | |
loadingAuto | booleanSet loading state automatically based on the | |
leading | booleanWhen | |
trailing | booleanWhen | |
loading | booleanWhen | |
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>) => string; label: (props?: Record<string, any>) => string; leadingIcon: (props?: Record<string, any>) => string; leadingAvatar: (props?: Record<string, any>) => string; leadingAvatarSize: (props?: Record<string, any>) => string; trailingIcon: (props?: Record<string, any>) => string; }; } |
default | { pohon: { base: (props?: Record<string, any>) => string; label: (props?: Record<string, any>) => string; leadingIcon: (props?: Record<string, any>) => string; leadingAvatar: (props?: Record<string, any>) => string; leadingAvatarSize: (props?: Record<string, any>) => string; trailingIcon: (props?: Record<string, any>) => string; }; } |
trailing | { pohon: { base: (props?: Record<string, any>) => string; label: (props?: Record<string, any>) => string; leadingIcon: (props?: Record<string, any>) => string; leadingAvatar: (props?: Record<string, any>) => string; leadingAvatarSize: (props?: Record<string, any>) => string; trailingIcon: (props?: Record<string, any>) => 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: ''
}
}
}
}
}
};