Skip to content

Add SlidingButton component#5398

Merged
hualf1995 merged 5 commits into
uber:mainfrom
Deliaz:denl/add-sliding-button
May 20, 2026
Merged

Add SlidingButton component#5398
hualf1995 merged 5 commits into
uber:mainfrom
Deliaz:denl/add-sliding-button

Conversation

@Deliaz
Copy link
Copy Markdown
Collaborator

@Deliaz Deliaz commented May 20, 2026

Summary

Adds the SlidingButton (swipe-to-confirm) component to the Base Design System. Uses a drag gesture instead of a tap to confirm actions, reducing accidental triggers and reinforcing user intent by introducing deliberate friction.

Props

Prop Type Default Description
label string (required) Text displayed on the track and repeated on the slider once completed
threshold 'high' | 'low' 'high' Drag distance required — high = 80%, low = 20% of track width
isLoading boolean false Shows a loading spinner, hides label and grabber, blocks interaction
isDisabled boolean false Grays out the component, blocks all interaction
onComplete () => void Callback fired once when the drag threshold is met or Enter/Space is pressed
slideBackAfterMs number Auto-resets the button to idle state after N ms
overrides SlidingButtonOverrides {} Override any of the 8 sub-elements: Root, Track, Slider, Label, CompletedLabel, Grabber, LoadingOverlay, LoadingSpinner
aria-label string Custom accessible label; defaults to label if not provided

Docs

Light theme Dark Theme
localhost_3000_components_sliding-button_ localhost_3000_components_sliding-button_ (1)

Ladle stories

image

What's included

  • Component (src/sliding-button/): constants, types, default-props, styled-components, component, index
  • Documentation: MDX page with Yard interactive playground, 3 example files (basic, states, low-threshold)

Test plan

  • TypeScript passes with zero errors from new files
  • Prettier formatting clean
  • npm run build:lib compiles successfully

Introduces the SlidingButton (swipe-to-confirm) component to the Base
Design System. Uses a drag gesture instead of a tap to confirm actions,
reducing accidental triggers and reinforcing user intent.

Features:
- Drag interaction with configurable threshold (high: 80%, low: 20%)
- Loading and disabled states
- Auto-reset via slideBackAfterMs
- Keyboard support (Enter / Space)
- RTL support
- Full override system (Root, Track, Slider, Label, CompletedLabel,
  Grabber, LoadingOverlay, LoadingSpinner)
- ARIA attributes (role, aria-label, aria-busy, aria-disabled, aria-live)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@hualf1995
Copy link
Copy Markdown
Collaborator

  1. Can you try to run the documentation site app locally and attach a screenshot in the PR description? I feel you may need to add it to route to make it show up in doc site. You can use this script to develop on doc site: https://github.com/uber/baseweb/blob/main/package.json#L16
  2. Can you add __tests__ for this component? (Unit tests and ubook stories can be added to this folder) You can start ubook dev with this script: https://github.com/uber/baseweb/blob/main/package.json#L17
  3. Can you please bump the package version? Since it is a new component, I believe npm version minor is fine.

Deliaz and others added 4 commits May 20, 2026 19:13
- Unit tests covering rendering, a11y attributes, keyboard interaction,
  loading/disabled states, slideBackAfterMs reset, and ref forwarding
- Ubook stories: default, states, low-threshold scenarios
- npm version minor (18.0.0 → 18.1.0)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replace markdown table (unsupported without remark-gfm) with bullet list.
Use 'at least N%' instead of '>N%' for clarity.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@Deliaz
Copy link
Copy Markdown
Collaborator Author

Deliaz commented May 20, 2026

  1. Can you try to run the documentation site app locally and attach a screenshot in the PR description? I feel you may need to add it to route to make it show up in doc site. You can use this script to develop on doc site: https://github.com/uber/baseweb/blob/main/package.json#L16
  2. Can you add __tests__ for this component? (Unit tests and ubook stories can be added to this folder) You can start ubook dev with this script: https://github.com/uber/baseweb/blob/main/package.json#L17
  3. Can you please bump the package version? Since it is a new component, I believe npm version minor is fine.

@hualf1995 Thanks! The PR has been updated.

  1. Added images for both Light and Dark themes. Added stories screenshot as well.
  2. Moved tests, but couldn't test them locally since test script & jest setup are not there. Do I miss something?
  3. Done.

@hualf1995
Copy link
Copy Markdown
Collaborator

  1. Can you try to run the documentation site app locally and attach a screenshot in the PR description? I feel you may need to add it to route to make it show up in doc site. You can use this script to develop on doc site: https://github.com/uber/baseweb/blob/main/package.json#L16
  2. Can you add __tests__ for this component? (Unit tests and ubook stories can be added to this folder) You can start ubook dev with this script: https://github.com/uber/baseweb/blob/main/package.json#L17
  3. Can you please bump the package version? Since it is a new component, I believe npm version minor is fine.

@hualf1995 Thanks! The PR has been updated.

  1. Added images for both Light and Dark themes. Added stories screenshot as well.
  2. Moved tests, but couldn't test them locally since test script & jest setup are not there. Do I miss something?
  3. Done.

As per the test, I think you are right! Jest setup seems not available here.

@hualf1995 hualf1995 merged commit 7e3beed into uber:main May 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants