Button Examples
The following command and toggle button examples demonstrate the button design pattern.
Similar examples include:
- Navigation Menu Button: A button that opens a menu of items that behave as links.
- Action Menu Button Example Using element.focus(): A button that opens a menu of actions or commands where focus in the menu is managed using
element.focus()
. - Action Menu Button Example Using aria-activedescendant: A button that opens a menu of actions or commands where focus in the menu is managed using aria-activedescendant.
Example
This Print
action button uses a div
element.
Print Page
This Mute
toggle button uses an a
element.
Keyboard Support
Key | Function |
---|---|
Enter | Activates the button. |
Space | Activates the button. |
Role, Property, State, and Tabindex Attributes
Role | Attribute | Element | Usage |
---|---|---|---|
button |
div , a
|
|
|
tabindex="0"
|
div , a
|
|
|
aria-pressed="false" |
a |
|
|
aria-pressed="true" |
a |
|
Javascript and CSS Source Code
- CSS: button.css
- Javascript: button.js
HTML Source Code