|
| 1 | +import Example from "../../components/example"; |
| 2 | +import Exports from "../../components/exports"; |
| 3 | +import Layout from "../../components/layout"; |
| 4 | +import SEO from "../../components/meta-seo"; |
| 5 | + |
| 6 | +import Basic from "examples/sliding-button/basic.tsx"; |
| 7 | +import States from "examples/sliding-button/states.tsx"; |
| 8 | +import LowThreshold from "examples/sliding-button/low-threshold.tsx"; |
| 9 | + |
| 10 | +import * as SlidingButtonExports from "baseui/sliding-button"; |
| 11 | + |
| 12 | +import Yard from "../../components/yard/index"; |
| 13 | +import slidingButtonYardConfig from "../../components/yard/config/sliding-button"; |
| 14 | + |
| 15 | +<SEO |
| 16 | + description="Sliding buttons use a drag gesture instead of a tap to confirm actions, reducing accidental triggers and reinforcing user intent." |
| 17 | + keywords="sliding button, swipe to confirm, slide to confirm, react drag button" |
| 18 | +/> |
| 19 | + |
| 20 | +export default Layout; |
| 21 | + |
| 22 | +# Sliding Button |
| 23 | + |
| 24 | +<Yard placeholderHeight={56} {...slidingButtonYardConfig} /> |
| 25 | + |
| 26 | +Sliding buttons are a variation of primary buttons that use a drag gesture instead of a standard tap to confirm actions. They help reduce accidental triggers and reinforce user intent by introducing deliberate friction. |
| 27 | + |
| 28 | +## When to use |
| 29 | + |
| 30 | +- **Prevent accidental actions**: Situations requiring confirmation to avoid unintended triggers. |
| 31 | +- **Costly or non-reversible actions**: Confirming intent on high-stakes operations (e.g., emergency assistance, trip completion). |
| 32 | +- **Multi-step flow completion**: Final step in extended user journeys. |
| 33 | + |
| 34 | +> **Caution**: If the action is not critical, a sliding button may add unnecessary complexity. Use a standard [Button](/components/button) instead. |
| 35 | +
|
| 36 | +## Examples |
| 37 | + |
| 38 | +<Example title="Basic usage" path="sliding-button/basic.tsx"> |
| 39 | + <Basic /> |
| 40 | +</Example> |
| 41 | + |
| 42 | +<Example |
| 43 | + title="States (default, loading, disabled)" |
| 44 | + path="sliding-button/states.tsx" |
| 45 | +> |
| 46 | + <States /> |
| 47 | +</Example> |
| 48 | + |
| 49 | +<Example |
| 50 | + title="Low threshold (20% drag)" |
| 51 | + path="sliding-button/low-threshold.tsx" |
| 52 | +> |
| 53 | + <LowThreshold /> |
| 54 | +</Example> |
| 55 | + |
| 56 | +## Threshold |
| 57 | + |
| 58 | +Two completion thresholds support different user types: |
| 59 | + |
| 60 | +- **`THRESHOLD.high`** (default) — at least 80% drag distance. Standard, requires deliberate intent. |
| 61 | +- **`THRESHOLD.low`** — at least 20% drag distance. For users with motor disabilities, seniors, or low-friction flows. |
| 62 | + |
| 63 | +## Accessibility |
| 64 | + |
| 65 | +- **Keyboard support**: Press Enter or Space to activate — provides a standard button interaction for screen reader users. |
| 66 | +- **Screen readers**: Use the `aria-label` prop to provide alternative text that omits "Slide" terminology, since swipe gestures behave differently with VoiceOver and TalkBack enabled. |
| 67 | +- The component sets `role="button"`, `aria-busy` during loading, and `aria-disabled` when disabled. |
| 68 | + |
| 69 | +## Content guidelines |
| 70 | + |
| 71 | +- **Use "Slide"** in the visible label to indicate the drag interaction. |
| 72 | +- **Avoid "Swipe"** — it carries a navigational connotation rather than task completion. |
| 73 | +- **Omit "Slide"** from `aria-label` when VoiceOver/TalkBack is expected — use the `aria-label` prop to provide a plain-language alternative. |
| 74 | + |
| 75 | +<Exports |
| 76 | + component={SlidingButtonExports} |
| 77 | + title="Sliding Button exports" |
| 78 | + path="baseui/sliding-button" |
| 79 | +/> |
0 commit comments