Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: TabsContent missing focus styles v2 (tailwind v4) -- a11y issue for keyboard navigation #7128

Open
2 tasks done
firxworx opened this issue Apr 5, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@firxworx
Copy link

firxworx commented Apr 5, 2025

Describe the bug

shadcn/ui v2 for tailwind v4 TabsContent of Tabs is missing focus:* / focus-visible:* styles for keyboard navigation.

Refer to tabs at https://v4.shadcn.com/

Compare to example of underlying radix-ui component at:
https://www.radix-ui.com/primitives/docs/components/tabs

Background:

When you keyboard navigate a common a11y pattern is for the TabsContent to be focusable. Therefore for keyboard navigation users it requires some sort of visual feedback to indicate that the tab content parent itself (i.e. not a child of it) has current focus.

Note per the radix-ui example how the style.css includes:

.TabsContent:focus {
	box-shadow: 0 0 0 2px black;
}

To slightly complicate what might look on the surface to be an easy fix.

This particular focus behaviour might not be desirable for a lot of developers / designers.

The W3C WAI ARIA provides examples of two patterns:

Note the difference with board navigation. With the latter, the tabs content body itself is not focusable and the next thing on the tab order after the tabs themselves is children of the tabs content.

I imagine for shadcn/ui developers might appreciate being to choose which pattern via props.

An example scenario where I can imagine devs complaining if shadcn/ui were to suddenly add focus styles to TabsContent is a Dialog that contains a tabbed interface (as a hypothetical example imagine radix-ui's tabs example was rendered in a modal Dialog).

Affected component/components

Tabs, TabsContent

How to reproduce

  1. Go to https://v4.shadcn.com/
  2. Scroll to the Tabs example and attempt to navigate with keyboard
  3. Note how there is no indication for what

Compare the UX to example at https://www.radix-ui.com/primitives/docs/components/tabs

Also compare tab navigation UX vs. W3C ARIA patterns:

https://www.w3.org/WAI/ARIA/apg/patterns/tabs/examples/tabs-automatic/
https://www.w3.org/WAI/ARIA/apg/patterns/tabs/examples/tabs-manual/

Codesandbox/StackBlitz link

No response

Logs

System Info

N/A - this is an a11y issue with missing styling

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@firxworx firxworx added the bug Something isn't working label Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant