Add rule about tabindex > 0 to the styleguide (#12981)

This commit is contained in:
Tim Roes 2017-07-22 07:48:02 +02:00 committed by GitHub
parent 7d08c68875
commit 2043cf0e0a

View file

@ -125,4 +125,10 @@ If something is meant to be clickable, favor using a `button` or `a` tag before
### Use `tabindex` to make elements tabbable
When added to the tab order, elements become focusable via non-sticky-mode keyboard navigation.
To add an element to the tab order, you must add an `id` attribute as well as a `tabindex` attribute. If you don't know which number to use for the tab index, or if you simply want to add it to the general flow of the document, use `tabindex="0"`.
To add an element to the tab order, you must add an `id` attribute as well as a `tabindex` attribute.
You should only use `tabindex="0"` to add an element to the tab flow or `tabindex="-1"` to remove an
otherwise focusable element from the focus flow (use with care).
You should never use a value greater than 0, since tabindex is a global counter for the whole
webpage and not scoped to parent elements, so you would need to manage a globally meaningful order
across all elements in the whole source code.