Skip to content

Commit

Permalink
Add sections on native interactive elements and tab order.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Jun 8, 2017
1 parent 20cf042 commit d2a25a2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions style_guides/html_style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This makes the attributes easier to scan and compare across similar elements.
The closing bracket should be on its own line. This allows attributes to be shuffled and edited without having to move the bracket around. It also makes it easier to scan vertically and match opening and closing brackets. This format
is inspired by the positioning of the opening and closing parentheses in [Pug/Jade](https://pugjs.org/language/attributes.html#multiline-attributes).

```
```html
<div
attribute1="value1"
attribute2="value2"
Expand All @@ -21,7 +21,7 @@ is inspired by the positioning of the opening and closing parentheses in [Pug/Ja

If the element doesn't have children, add the closing tag on the same line as the opening tag's closing bracket.

```
```html
<div
attribute1="value1"
attribute2="value2"
Expand Down Expand Up @@ -62,4 +62,13 @@ described element can point to with the `aria-describedby` attribute. For exampl
<button aria-describedby="visualizationsTooltip">
Visualizations
</button>
```
```

### Prefer `button` and `a` when making interactive elements keyboard-accessible

If something is meant to be clickable, favor using a `button` or `a` tag before over the `kui-accessible-click` directive or `KuiKeyboardAccessible` component. These tools are useful as they augment non-clickable elements with `onkeypress` and `onkeyup` handlers, allowing non-clickable elements to become keyboard accessible. However, `button` and `a` tags provide this functionality natively.

### 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"`.

0 comments on commit d2a25a2

Please sign in to comment.