Skip to content

feat(react-switch): add useSwitchBase_unstable hook#35820

Draft
dmytrokirpa wants to merge 1 commit intomasterfrom
feat/react-switch-base-hooks
Draft

feat(react-switch): add useSwitchBase_unstable hook#35820
dmytrokirpa wants to merge 1 commit intomasterfrom
feat/react-switch-base-hooks

Conversation

@dmytrokirpa
Copy link
Contributor

Summary

  • Enables the public API for useSwitchBase_unstable hook in react-switch
  • Exports useSwitchBase_unstable hook from the package index.ts
  • Exports SwitchBaseProps and SwitchBaseState types from the package index.ts

The implementation was already present on the experimental branch (added in an earlier commit) but the exports were commented out with a note "Experimental APIs - will be uncommented in experimental branch". This PR enables those exports.

What the base hook includes

useSwitchBase_unstable manages:

  • Slot structure (root, indicator, input, label slots)
  • role="switch" ARIA attribute on input
  • Checked/unchecked state (controlled and uncontrolled)
  • labelPosition structural prop
  • Focus management via useFocusWithin
  • Field integration via useFieldControlProps_unstable
  • onChange callback with typed data

useSwitchBase_unstable excludes:

  • size prop (small/medium - design concern)

Test plan

  • Verify useSwitchBase_unstable can be imported from @fluentui/react-switch
  • Verify SwitchBaseProps and SwitchBaseState types are exported
  • Verify existing useSwitch_unstable behavior is unchanged

🤖 Generated with Claude Code

@dmytrokirpa dmytrokirpa force-pushed the feat/react-switch-base-hooks branch from 0f5ed9f to 3a4afe0 Compare March 5, 2026 11:04
@dmytrokirpa dmytrokirpa changed the base branch from experimental/component-base-hooks to master March 5, 2026 11:04
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

📊 Bundle size report

✅ No changes found

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Pull request demo site: URL

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