Skip to content

feat(react-switch): expose base hook and types for Switch component#35820

Merged
dmytrokirpa merged 3 commits intomasterfrom
feat/react-switch-base-hooks
Mar 23, 2026
Merged

feat(react-switch): expose base hook and types for Switch component#35820
dmytrokirpa merged 3 commits intomasterfrom
feat/react-switch-base-hooks

Conversation

@dmytrokirpa
Copy link
Contributor

@dmytrokirpa dmytrokirpa commented Mar 3, 2026

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)

🤖 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

@dmytrokirpa dmytrokirpa changed the title feat(react-switch): add useSwitchBase_unstable hook feat(react-switch): expose base hook and types for Switch component Mar 20, 2026
@dmytrokirpa dmytrokirpa enabled auto-merge (squash) March 20, 2026 20:47
@dmytrokirpa dmytrokirpa merged commit 4267b29 into master Mar 23, 2026
15 checks passed
@dmytrokirpa dmytrokirpa deleted the feat/react-switch-base-hooks branch March 23, 2026 13:36
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.

2 participants