Skip to content

feat: add Switch component#2301

Draft
ezirlingerDQ wants to merge 3 commits intodevelopfrom
feat/switch-component
Draft

feat: add Switch component#2301
ezirlingerDQ wants to merge 3 commits intodevelopfrom
feat/switch-component

Conversation

@ezirlingerDQ
Copy link
Copy Markdown

Summary

  • Add a new accessible Switch toggle component with full ARIA role="switch" support
  • Include controlled/uncontrolled state management, disabled state, error messages, and label descriptions
  • Add CSS styles with dark/light theme support via custom properties
  • Add comprehensive test suite and MDX documentation with live examples

Test plan

  • Run yarn test and verify all Switch tests pass
  • Run yarn dev and verify the Switch docs page renders at /components/Switch
  • Test keyboard navigation (Space/Enter to toggle, Tab to focus)
  • Verify screen reader announces switch state correctly
  • Check dark and light theme rendering

Add an accessible toggle switch component with full ARIA support,
controlled/uncontrolled state management, error handling, and
comprehensive documentation.
@ezirlingerDQ ezirlingerDQ requested review from a team as code owners April 3, 2026 17:26
@aws-amplify-us-east-1
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-2301.d15792l1n26ww3.amplifyapp.com

Add jest-axe tests covering all states: unchecked, checked, disabled,
disabled checked, error, and label description per CONTRIBUTING.md
requirements.
height: 24px;
border: 2px solid var(--switch-track-color);
border-radius: 999px;
padding: 4px;
Copy link
Copy Markdown
Collaborator

@anastasialanz anastasialanz Apr 3, 2026

Choose a reason for hiding this comment

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

This should be var(--space-half) for 4px.

Comment on lines +5 to +8
--switch-track-color-checked-disabled: var(
--accent-primary-disabled,
#78a6d8
);
Copy link
Copy Markdown
Collaborator

@anastasialanz anastasialanz Apr 3, 2026

Choose a reason for hiding this comment

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

#78a6d8 is the same as --accent-primary-disabled which seems unnecessary.

:root {
--switch-track-color: var(--gray-90);
--switch-track-color-checked: var(--accent-primary);
--switch-track-color-disabled: var(--gray-40);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be var(--disabled) instead?

#78a6d8
);
--switch-handle-color: var(--gray-90);
--switch-handle-color-disabled: var(--gray-40);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be var(--disabled) instead?

@@ -0,0 +1,2 @@
export { default, Switch } from './Switch';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These exports are redundant and should probably follow how we do it in other components like export { default as ActionMenu } from './ActionMenu';

Suggested change
export { default, Switch } from './Switch';
export { default as Switch } from './Switch';

@anastasialanz anastasialanz marked this pull request as draft April 6, 2026 18:21
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