Slider · Simple slider
Loading preview...
Component
安装 Installation
用法 Usage
className 与 variant、size 可以一起用。字段以 timkit agent inspect slider --json 的 props 为准。
示例
一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。
27 / 27
结构化 API
与 UCS schema 对齐的 props、逻辑机与多框架运行时。
Component
slider
Logic
zag / slider
Runtime Frameworks
Supported Platforms
| Prop | Type | Default | Description |
|---|---|---|---|
| logic.provider* | enum (zag | native | none) | zag | State and interaction provider used by this component. |
| logic.machine | string | slider | Underlying state machine identifier when provider is zag. |
| platforms* | array | Web, WeChat Mini Program | Platforms officially supported by this schema. |
| frameworks* | array | React, Vue, Weapp, HTML | Framework demos/code currently available in registry files. |
| dependencies | array | @timui/core, @zag-js/react | Runtime package dependencies required by this registry item. |
| optionalPeerDependencies | array | - | Optional peer dependencies used by this registry item. |
| registryDependencies | array | https://ui.timkit.cn/r/tooltip.json, use-machine | Dependent Timkit registry components/hook entries. |
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | - | The controlled value. |
| disabled | boolean | false | Whether the slider is disabled. |
| readOnly | boolean | false | When true, value changes are ignored. |
| min | number | 0 | The minimum value. |
| max | number | 100 | The maximum value. |
| step | number | 1 | The step value. |
| orientation | enum (horizontal | vertical) | horizontal | Horizontal sliders move with Left and Right. Vertical sliders move with Up and Down. |
| Prop | Type | Default | Description |
|---|---|---|---|
| onValueChange | event | - | Callback called when value changes. |
来自 TypeScript 导出。
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | - | Input behavior configuration for id. |
| showTooltip | boolean | - | Whether to show thumb tooltip labels. |
| modelValue | number | - | The controlled value bound via `v-model` (Vue specific). |
| defaultValue | number | - | The default value of the component when uncontrolled. |
| ids | enum (ids) | - | The ids of the elements in the slider. Useful for composition. |
| dir | enum (dir) | - | The text direction. |
| name | string | - | Accessible labels for slider thumbs. / 'aria-label'?: slider.Props['aria-label'] /** Accessible labelled-by ids for slider thumbs. / 'aria-labelledby'?: slider.Props['aria-labelledby'] /** The name associated with each slider thumb. |
| form | string | - | The associated form id. |
| invalid | boolean | - | Whether the slider is invalid. |
| minStepsBetweenThumbs | number | - | The minimum steps between thumbs for multi-thumb sliders. |
| origin | enum (start | center | end) | - | The origin of the slider range. |
| thumbAlignment | enum (contain | center) | - | Thumb alignment relative to track. |
| thumbSize | enum (thumbSize) | - | Thumb dimensions. |
| thumbCollisionBehavior | enum (none | push | swap) | - | Collision behavior when thumbs cross. |
| getAriaValueText | enum (getAriaValueText) | - | Function that returns a readable value for a thumb. |
| tooltipContent | event | - | Custom formatter for tooltip labels. |
| onFocusChange | enum (onFocusChange) | - | Callback fired when focused thumb changes. |
| onValueChangeEnd | event | - | Callback fired when value commit ends. |
| Prop | Type | Default | Description |
|---|---|---|---|
| default | slot | - | Default slot content rendered inside the component root. |
| Prop | Type | Default | Description |
|---|---|---|---|
| root* | root | - | The slider container |
| track | part | - | The slider track |
| range | part | - | The filled part of the track |
| thumb | part | - | The handler to slide |
该组件尚无扩展说明文档。
键盘与焦点
跨 React、Vue 与小程序共享的交互与可读名称约定。
行为契约
props、默认值和运行时状态。