Skip to content

feat(react-slider): add useSliderBase_unstable hook#35815

Draft
dmytrokirpa wants to merge 2 commits intomasterfrom
feat/react-slider-base-hooks
Draft

feat(react-slider): add useSliderBase_unstable hook#35815
dmytrokirpa wants to merge 2 commits intomasterfrom
feat/react-slider-base-hooks

Conversation

@dmytrokirpa
Copy link
Contributor

Summary

  • Adds useSliderBase_unstable hook to react-slider that extracts pure component logic without design props
  • Adds SliderBaseProps type omitting size (design-related prop); vertical is kept as it affects aria-orientation behavior via the orient attribute on the input element
  • Adds SliderBaseState type omitting size
  • Refactors useSlider_unstable to call useSliderBase_unstable internally
  • Exports new types and hook from package index.ts

What base hooks include

The base hook preserves:

  • Slot structure (root, input, rail, thumb slots)
  • type="range" on input
  • orient attribute (horizontal/vertical) for Firefox support
  • Focus management via useFocusWithin
  • Controlled/uncontrolled value state via useSliderState_unstable
  • Field integration via useFieldControlProps_unstable
  • disabled and vertical behavioral props

The base hook excludes:

  • size prop (small/medium - design concern)

Test plan

  • Verify useSliderBase_unstable can be imported from @fluentui/react-slider
  • Verify SliderBaseProps and SliderBaseState types are exported
  • Verify existing useSlider_unstable behavior is unchanged
  • Verify slider without size prop still functions correctly

🤖 Generated with Claude Code

dmytrokirpa and others added 2 commits March 5, 2026 11:55
Adds a base state hook for Slider component that extracts pure component logic
(ARIA, slot structure, keyboard handling, controlled/uncontrolled state) without
the design-related size prop.

- Add SliderBaseProps type omitting size (design prop); keeps vertical as it
  affects aria-orientation behavior via the orient attribute on the input
- Add SliderBaseState type omitting size
- Add useSliderBase_unstable hook that handles slot setup, focus management,
  and delegates controlled state to useSliderState_unstable
- Refactor useSlider_unstable to call useSliderBase_unstable internally
- Export new types and hook from package index.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dmytrokirpa dmytrokirpa changed the base branch from experimental/component-base-hooks to master March 5, 2026 10:56
@dmytrokirpa dmytrokirpa force-pushed the feat/react-slider-base-hooks branch from 72222f8 to 70334a1 Compare March 5, 2026 10:56
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Pull request demo site: URL

@@ -0,0 +1,7 @@
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/CalendarCompat 4 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/CalendarCompat.multiDayView - High Contrast.default.chromium.png 1236 Changed
vr-tests-react-components/CalendarCompat.multiDayView - Dark Mode.default.chromium.png 1107 Changed
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium_1.png 403 Changed
vr-tests-react-components/CalendarCompat.multiDayView - RTL.default.chromium.png 495 Changed
vr-tests-react-components/Charts-DonutChart 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic.default.chromium.png 5581 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic - Dark Mode.default.chromium.png 7530 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 609 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 506 Changed
vr-tests-react-components/TagPicker 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.chromium.png 658 Changed
vr-tests-react-components/TagPicker.disabled - High Contrast.disabled input hover.chromium.png 1319 Changed
vr-tests-react-components/TagPicker.disabled - RTL.disabled input hover.chromium.png 635 Changed

There were 4 duplicate changes discarded. Check the build logs for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant