Skip to content

Add XDSSlider component - #116

Merged
cixzhang merged 9 commits into
mainfrom
XDSSlider
Feb 18, 2026
Merged

cixzhang merged 9 commits into
mainfrom
XDSSlider

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Implements the slider component per the spec in #37.

Features

  • Single thumb: value: number for simple value selection
  • Range: value: [number, number] for min/max range selection
  • Marks: Tick marks with optional labels
  • Value display: Tooltip (on hover/drag), text (inline), or none
  • Keyboard: Arrow keys, Page Up/Down, Home/End
  • formatValue: Custom value formatting function

Design decisions

  • Discriminated union for single vs range — dominant pattern (Radix, MUI, Ant). Less API surface for LLMs.
  • onChangeEnd (not onChangeSettled) — most common name (React Aria, Mantine)
  • min/max (not minValue/maxValue) — corpus standard
  • isLabelHidden defaults to false — accessibility-first (internal defaulted to true for backward compat)
  • Unified status object — matches input family

Follows

  • Input props convention: .context/decisions/input-props-convention.md
  • Sibling patterns: TextInput, Switch, CheckboxInput

Closes #37

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 17, 2026
@cixzhang cixzhang mentioned this pull request Feb 17, 2026
@github-actions

github-actions Bot commented Feb 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

New Components

Slider
Metric Value
Bundle Size (ESM) 365B
Bundle Size (CJS) 478B
Lines of Code 607
Source Files 2
Complexity Very High (75)
Exports XDSSlider
Props Count N/A
Has Tests Yes
Has Stories Yes

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 5.9KB 9.7KB 1.6KB

Accessibility Audit

Status: 1 accessibility violation(s) found.

XDSSlider - 1 issue(s)
  • serious: Links must have discernible text
    • Rule: link-name

Component Previews

Includes interactive hover previews as animated GIFs.

XDSSlider

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

Run yarn storybook and navigate to: core-xdsslider--default

Range

Screenshot:

Range

Interaction Preview: (view video)

Range interaction

Run yarn storybook and navigate to: core-xdsslider--range

With Marks

Screenshot:

With Marks

Interaction Preview: (view video)

With Marks interaction

Run yarn storybook and navigate to: core-xdsslider--with-marks

Custom Step

Screenshot:

Custom Step

Interaction Preview: (view video)

Custom Step interaction

Run yarn storybook and navigate to: core-xdsslider--custom-step

With Format Value

Screenshot:

With Format Value

Interaction Preview: (view video)

With Format Value interaction

Run yarn storybook and navigate to: core-xdsslider--with-format-value

Disabled

Screenshot:

Disabled

Interaction Preview: (view video)

Disabled interaction

Run yarn storybook and navigate to: core-xdsslider--disabled

Vertical Orientation

Screenshot:

Vertical Orientation

Interaction Preview: (view video)

Vertical Orientation interaction

Run yarn storybook and navigate to: core-xdsslider--vertical-orientation

With Status

Screenshot:

With Status

Interaction Preview: (view video)

With Status interaction

Run yarn storybook and navigate to: core-xdsslider--with-status

All Variations

Screenshot:

All Variations

Interaction Preview: (view video)

All Variations interaction

Run yarn storybook and navigate to: core-xdsslider--all-variations


Generated by PR Enrichment workflow | Storybook | View full report

@cixzhang

Copy link
Copy Markdown
Contributor Author

Slide container has 28px height despite the contents being 20px. We probably shouldn't hardcode that height since we're also applying another 4px margin on the status messages afterwards which makes slider + status appear to ahve 8px between.

@cixzhang

Copy link
Copy Markdown
Contributor Author

Slider thumb in dark mode is difficult to see. Will likely want to use the popover background instead of the card/surface.

@cixzhang

Copy link
Copy Markdown
Contributor Author

Let's make sure slider follows the input guidance and convention for props (ex. description, etc).

@cixzhang

Copy link
Copy Markdown
Contributor Author

Comparing with our internal slider, the thumb should be using the accent color and match the bar, then have a surface-colored output.

Screenshot 2026-02-17 at 1 26 44 PM

We should include a disabled state which shows gray thumb and bar.

Also include a description prop and follow input API conventions.

Comment thread packages/core/src/Slider/XDSSlider.tsx Resolved
Implements slider with:
- Discriminated union: number (single) vs [number, number] (range)
- Pointer-based drag with setPointerCapture
- Full keyboard support (arrows, page up/down, home/end)
- Value display modes: tooltip, text, none
- Marks with optional labels
- formatValue for custom value formatting
- Follows input family conventions (label, status, etc.)

Closes #37
Add left: 50% for horizontal tooltip and top: 50% for vertical tooltip
so they center correctly relative to the thumb element.
Replace manual tooltip positioning with XDSTooltip component which
handles centering via CSS anchor positioning. Removes custom tooltip
styles and thumb hover/focus/active state tracking — XDSTooltip
manages visibility on hover and focus automatically.

- delay={0} for immediate show
- focusTrigger='always' for keyboard interaction
- placement='above' (horizontal) or 'before' (vertical)
1. Track container height: Remove extra 8px padding (was THUMB_SIZE+8,
   now THUMB_SIZE). Fixes excessive spacing between slider and status.

2. Thumb dark mode: Use --color-popover instead of --color-surface for
   better visibility in dark mode.

3. Use XDSField wrapper: Replace manual XDSFieldLabel + description +
   XDSFieldStatus with XDSField, matching TextInput/Selector pattern.
   Status messages now use attached variant (directly below track).
- Thumb uses --color-accent background (matching filled track) with
  a --color-surface inner dot, matching the internal slider design
- Disabled thumb uses --color-deemphasized (gray)
- Hover state uses color-mix for accent tint
- Focus outline via :focus-within on the thumb div — shows
  2px solid --color-focus-outline with 2px offset on keyboard focus
- Removed elevation shadow (replaced by accent color design)
Revert from XDSField (attached status) to XDSFieldLabel + XDSFieldStatus
with variant='detached'. The slider track isn't a bordered input box,
so detached status is the right pattern (matching CheckboxInput/Switch).
The previous gap issue was from the container height, not the status variant.
- Remove inner dot from thumb — now solid accent color as designed
- Fix vertical thumb position: use translate(-50%, 50%) instead of
  translate(-50%, -50%) for bottom-positioned elements so thumb
  centers correctly on its track position
- Remove unused display:flex/alignItems/justifyContent from thumb
Replace manual XDSFieldLabel + XDSFieldStatus composition with
XDSField wrapper using the new statusVariant prop.
@cixzhang
cixzhang merged commit cad38d3 into main Feb 18, 2026
5 checks passed
@cixzhang
cixzhang deleted the XDSSlider branch February 18, 2026 00:33
cixzhang added a commit that referenced this pull request Apr 26, 2026
* Add XDSSlider component with single and range support

Implements slider with:
- Discriminated union: number (single) vs [number, number] (range)
- Pointer-based drag with setPointerCapture
- Full keyboard support (arrows, page up/down, home/end)
- Value display modes: tooltip, text, none
- Marks with optional labels
- formatValue for custom value formatting
- Follows input family conventions (label, status, etc.)

Closes #37

* Fix tooltip centering above slider thumb

Add left: 50% for horizontal tooltip and top: 50% for vertical tooltip
so they center correctly relative to the thumb element.

* Use XDSTooltip for slider value display

Replace manual tooltip positioning with XDSTooltip component which
handles centering via CSS anchor positioning. Removes custom tooltip
styles and thumb hover/focus/active state tracking — XDSTooltip
manages visibility on hover and focus automatically.

- delay={0} for immediate show
- focusTrigger='always' for keyboard interaction
- placement='above' (horizontal) or 'before' (vertical)

* Address PR feedback: container height, thumb color, XDSField wrapper

1. Track container height: Remove extra 8px padding (was THUMB_SIZE+8,
   now THUMB_SIZE). Fixes excessive spacing between slider and status.

2. Thumb dark mode: Use --color-popover instead of --color-surface for
   better visibility in dark mode.

3. Use XDSField wrapper: Replace manual XDSFieldLabel + description +
   XDSFieldStatus with XDSField, matching TextInput/Selector pattern.
   Status messages now use attached variant (directly below track).

* Fix: use valid LayerPlacement 'start' instead of 'before'

* Update slider thumb to accent color with inner dot + focus outline

- Thumb uses --color-accent background (matching filled track) with
  a --color-surface inner dot, matching the internal slider design
- Disabled thumb uses --color-deemphasized (gray)
- Hover state uses color-mix for accent tint
- Focus outline via :focus-within on the thumb div — shows
  2px solid --color-focus-outline with 2px offset on keyboard focus
- Removed elevation shadow (replaced by accent color design)

* Use detached status pattern for slider

Revert from XDSField (attached status) to XDSFieldLabel + XDSFieldStatus
with variant='detached'. The slider track isn't a bordered input box,
so detached status is the right pattern (matching CheckboxInput/Switch).
The previous gap issue was from the container height, not the status variant.

* Fix slider: solid accent thumb, fix vertical positioning

- Remove inner dot from thumb — now solid accent color as designed
- Fix vertical thumb position: use translate(-50%, 50%) instead of
  translate(-50%, -50%) for bottom-positioned elements so thumb
  centers correctly on its track position
- Remove unused display:flex/alignItems/justifyContent from thumb

* Use XDSField with statusVariant='detached' for Slider

Replace manual XDSFieldLabel + XDSFieldStatus composition with
XDSField wrapper using the new statusVariant prop.
cixzhang added a commit that referenced this pull request Jun 21, 2026
* Add XDSSlider component with single and range support

Implements slider with:
- Discriminated union: number (single) vs [number, number] (range)
- Pointer-based drag with setPointerCapture
- Full keyboard support (arrows, page up/down, home/end)
- Value display modes: tooltip, text, none
- Marks with optional labels
- formatValue for custom value formatting
- Follows input family conventions (label, status, etc.)

Closes #37

* Fix tooltip centering above slider thumb

Add left: 50% for horizontal tooltip and top: 50% for vertical tooltip
so they center correctly relative to the thumb element.

* Use XDSTooltip for slider value display

Replace manual tooltip positioning with XDSTooltip component which
handles centering via CSS anchor positioning. Removes custom tooltip
styles and thumb hover/focus/active state tracking — XDSTooltip
manages visibility on hover and focus automatically.

- delay={0} for immediate show
- focusTrigger='always' for keyboard interaction
- placement='above' (horizontal) or 'before' (vertical)

* Address PR feedback: container height, thumb color, XDSField wrapper

1. Track container height: Remove extra 8px padding (was THUMB_SIZE+8,
   now THUMB_SIZE). Fixes excessive spacing between slider and status.

2. Thumb dark mode: Use --color-popover instead of --color-surface for
   better visibility in dark mode.

3. Use XDSField wrapper: Replace manual XDSFieldLabel + description +
   XDSFieldStatus with XDSField, matching TextInput/Selector pattern.
   Status messages now use attached variant (directly below track).

* Fix: use valid LayerPlacement 'start' instead of 'before'

* Update slider thumb to accent color with inner dot + focus outline

- Thumb uses --color-accent background (matching filled track) with
  a --color-surface inner dot, matching the internal slider design
- Disabled thumb uses --color-deemphasized (gray)
- Hover state uses color-mix for accent tint
- Focus outline via :focus-within on the thumb div — shows
  2px solid --color-focus-outline with 2px offset on keyboard focus
- Removed elevation shadow (replaced by accent color design)

* Use detached status pattern for slider

Revert from XDSField (attached status) to XDSFieldLabel + XDSFieldStatus
with variant='detached'. The slider track isn't a bordered input box,
so detached status is the right pattern (matching CheckboxInput/Switch).
The previous gap issue was from the container height, not the status variant.

* Fix slider: solid accent thumb, fix vertical positioning

- Remove inner dot from thumb — now solid accent color as designed
- Fix vertical thumb position: use translate(-50%, 50%) instead of
  translate(-50%, -50%) for bottom-positioned elements so thumb
  centers correctly on its track position
- Remove unused display:flex/alignItems/justifyContent from thumb

* Use XDSField with statusVariant='detached' for Slider

Replace manual XDSFieldLabel + XDSFieldStatus composition with
XDSField wrapper using the new statusVariant prop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slider

1 participant