tailwindcss-stimulus-components
tailwindcss-stimulus-components copied to clipboard
Tabs: Add support for horizontal scrolling
I'm using horizontal scrollable tabs in my current project, so the active tab may be out of sight after connecting the controller.
This PR fixes this by changing two things:
- The active tab always gets the attribute
aria-selected="true"
- Using
scrollIntoView()
ensures that the active tab is visible
References:
- https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected
- https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaSelected
- https://developer.mozilla.org/de/docs/Web/API/Element/scrollIntoView