Usage
Use the Accordion component to display a list of collapsible items.
{
"wait": "Loading client-side content..."
}Items
Use the items prop as an array of objects with the following properties:
label?: stringicon?: IconComponenttrailingIcon?: IconComponentcontent?: stringvalue?: stringdisabled?: booleanslot?: stringclass?: anyb24ui?: { item?: ClassNameValue, header?: ClassNameValue, trigger?: ClassNameValue, leadingIcon?: ClassNameValue, label?: ClassNameValue, trailingIcon?: ClassNameValue, content?: ClassNameValue, body?: ClassNameValue }
{
"wait": "Loading client-side content..."
}Multiple
Set the type prop to multiple to allow multiple items to be active at the same time. Defaults to single.
{
"wait": "Loading client-side content..."
}Collapsible
When type is single, you can set the collapsible prop to false to prevent the active item from collapsing.
{
"wait": "Loading client-side content..."
}Unmount
Use the unmount-on-hide prop to prevent the content from being unmounted when the accordion is collapsed. Defaults to true.
{
"wait": "Loading client-side content..."
}Disabled
Use the disabled property to disable the Accordion.
You can also disable a specific item by using the disabled property in the item object.
{
"wait": "Loading client-side content..."
}Trailing Icon
Use the trailing-icon prop to customize the trailing Icon of each item.
trailingIcon property in the item object.{
"wait": "Loading client-side content..."
}Examples
Control active item(s)
You can control the active item by using the default-value prop or the v-model directive with the value of the item. If no value is provided, it defaults to the index as a string.
type="multiple", ensure to pass an array to the default-value prop or the v-model directive.With drag and drop
Use the useSortable composable from @vueuse/integrations to enable drag and drop functionality on the Accordion. This integration wraps Sortable.js to provide a seamless drag and drop experience.
With body slot
Use the #body slot to customize the body of each item.
#body slot includes some pre-defined styles, use the #content slot if you want to start from scratch.With content slot
Use the #content slot to customize the content of each item.
With custom slot
Use the slot property to customize a specific item.
You will have access to the following slots:
#{{ item.slot }}#{{ item.slot }}-body
With markdown content
You can use the MDC component from @nuxtjs/mdc to render markdown in the accordion items.
online service for business management and work automation. It contains tools for companies of all sizes and industries. Bitrix24 has several plans with different sets of tools that are suitable for different types of business.API
Props
Slots
Emits
Theme
export default defineAppConfig({
b24ui: {
accordion: {
slots: {
root: 'w-full',
item: 'text-(--b24ui-typography-label-color) border-b border-(--ui-color-divider-vibrant-accent-more) last:border-b-0',
header: 'flex',
trigger: 'min-w-0 group flex-1 flex items-center gap-1.5 py-[12px] font-(--ui-font-weight-medium) text-(length:--ui-font-size-sm) leading-[20px] focus-visible:outline-(--ui-color-accent-soft-element-blue) cursor-pointer',
content: 'motion-safe:data-[state=open]:animate-[accordion-down_200ms_ease-out] motion-safe:data-[state=closed]:animate-[accordion-up_200ms_ease-out] overflow-hidden focus:outline-none',
body: 'text-(length:--ui-font-size-sm) pb-[12px]',
leadingIcon: 'shrink-0 size-[20px]',
trailingIcon: 'shrink-0 size-[20px] ms-auto group-data-[state=open]:rotate-180 transition-transform duration-200',
label: 'text-start break-words'
},
variants: {
disabled: {
true: {
trigger: 'cursor-not-allowed opacity-75'
}
}
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import bitrix24UIPluginVite from '@bitrix24/b24ui-nuxt/vite'
export default defineConfig({
plugins: [
vue(),
bitrix24UIPluginVite({
b24ui: {
accordion: {
slots: {
root: 'w-full',
item: 'text-(--b24ui-typography-label-color) border-b border-(--ui-color-divider-vibrant-accent-more) last:border-b-0',
header: 'flex',
trigger: 'min-w-0 group flex-1 flex items-center gap-1.5 py-[12px] font-(--ui-font-weight-medium) text-(length:--ui-font-size-sm) leading-[20px] focus-visible:outline-(--ui-color-accent-soft-element-blue) cursor-pointer',
content: 'motion-safe:data-[state=open]:animate-[accordion-down_200ms_ease-out] motion-safe:data-[state=closed]:animate-[accordion-up_200ms_ease-out] overflow-hidden focus:outline-none',
body: 'text-(length:--ui-font-size-sm) pb-[12px]',
leadingIcon: 'shrink-0 size-[20px]',
trailingIcon: 'shrink-0 size-[20px] ms-auto group-data-[state=open]:rotate-180 transition-transform duration-200',
label: 'text-start break-words'
},
variants: {
disabled: {
true: {
trigger: 'cursor-not-allowed opacity-75'
}
}
}
}
}
})
]
})