Component

Accordion

安装 Installation

npx timkit add accordion --yes --framework react

用法 Usage

import { Accordion } from "@/components/ui/accordion"

className 与 variant、size 可以一起用。字段以 timkit agent inspect accordion --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

20 / 20

Accordion · With chevron

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

accordion

Logic

zag / accordion

Runtime Frameworks

ReactVueWeappHTML

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
zagState and interaction provider used by this component.
logic.machine
string
accordionUnderlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
React, Vue, Weapp, HTMLFramework demos/code currently available in registry files.
dependencies
array
@timui/core, @zag-js/reactRuntime package dependencies required by this registry item.
optionalPeerDependencies
array
lucide-reactOptional peer dependencies used by this registry item.
registryDependencies
array
use-machineDependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
value
string
-The controlled value of the accordion items to expand.
type
enum (single | multiple)
singleThe selection mode of the accordion.
collapsible
boolean
falseWhether a single accordion item can be collapsed after it has been opened.
disabled
boolean
falseWhether the accordion is disabled.

Events

PropTypeDefaultDescription
onValueChange
event
-Event handler called when the value changes.

TypeScript

来自 TypeScript 导出。

PropTypeDefaultDescription
id
string
-Navigation structure and state configuration for id.
defaultValue
string
-Initial value in uncontrolled mode.

Slots

PropTypeDefaultDescription
default
slot
-The accordion items

Parts

PropTypeDefaultDescription
root*
root
-The accordion container
item
part
-An accordion item
trigger
part
-The toggle button for an item
content
part
-The collapsible content section
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • ArrowDown moves to the next item without opening it and skips a disabled item.
  • Home moves to the first enabled item.
  • End moves to the last.
  • Enter or Space opens the focused item.
  • Each enabled trigger is in the tab order.
  • One open item is visible as Item N of the item count.
  • Several open items read how many are open.
  • An empty value has no item status.
  • A disabled item ignores those keys.
  • A disabled accordion leaves every trigger out of the tab order.
  • The marker beside a trigger is not part of its name.
  • The trigger controls the panel.
  • The panel is named by the trigger.
  • On the mini program, aria-controls is set only while the panel is open.

行为契约

Contract

props、默认值和运行时状态。

  • A single accordion keeps the open item open unless collapsible is true.
  • Multiple mode can open every item.