Skip to content

Not accessible by default #23

Description

@tknickman

Because this uses an svg element, it is not keyboard accessible by default. You can fix this manually by wrapping the component in a button with a key handler, but it would be great if this was supported out of the box.

For example I have fixed this with:

<button
  onKeyDown={(e) => e.code === "Enter" && toggleTheme()}
  aria-label={`switch to ${
    colorTheme === themes.DARK ? "dark" : "light"
  } mode`}
>
  <DarkModeSwitch
    checked={colorTheme === themes.DARK}
    onChange={toggleTheme}
    ...
  />
</button>

This should be keyboard accessible (can be tabbed to, and selected with enter) by default.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions