滑动操作
滑动列表中的一行即可显示左侧或右侧的操作。
- Dependencies (2)
功能
构建于 React 滑动操作 之上。
- 用指针或触摸拖动。
- 距离或轻轻一按即可打开。完全滑动会运行最外面的操作。
- 一次仅打开一行,通过外部点击即可关闭。
安装
pnpm dlx shadcn@latest add @yourname/swipe-actions
用法
import {
SwipeAction,
SwipeActions,
SwipeContent,
SwipeItem,
SwipeRoot,
} from "@/components/swipe-actions"<SwipeRoot>
<SwipeItem>
<SwipeActions side="right" fullSwipe>
<SwipeAction />
<SwipeAction />
</SwipeActions>
<SwipeContent />
</SwipeItem>
</SwipeRoot>成分
使用以下组合构建 SwipeItem
SwipeRoot
└── SwipeItem
├── SwipeActions
│ └── SwipeAction
└── SwipeContent示例
最小
有效的最小设置:一侧执行一个操作。
选择完整的滑动动作
完全滑动会执行最外层的操作,因此请与安全的一起订购该条带 最后。此处“删除”位于该行旁边,但仍需要刻意点击。
无障碍
- 箭头键打开聚焦行,
Escape关闭它。 - 封闭的条带是
inert,因此他们的动作无法触及。 - 尊重
prefers-reduced-motion。
参考
License and usage
- Free to use and modify in both personal and commercial projects.
- Attribution is appreciated but not required.
- Released under the MIT License.
Every component here is built and maintained by one person. If you enjoy using them, you can sponsor my work.