Usando o slider role

Esta tradução está incompleta. Ajude atraduzir este artigo.


Essa técnica demosntrará como usar o slider role. 

The slider role is used for markup that allows a user to select a value from within a given range. The slider role is assigned to the "thumb," the control that is adjusted to change the value. Typically, another element is styled to visually represent the range of possible valued, and the thumb positioned visually to represent the value within that range. As the user interacts with the thumb, the application must programmatically adjust the slider's aria-valuenow (and possible aria-valuetext) attribute to reflect the current value. See the Examples section below for more information.

Keyboard And Focus

The slider should be keyboard focusable and operable. When the user tabs focus to the slider, it should land on the thumb: the control a mouse user would drag. Arrow keys should operate as follows (localization for right-to-left languages should reverse the direction of the arrows):

Tecla(s) Ação
Setas para direita e para cima  Incrementa o valor selecionado
Setas para esquerda e para baixo Decrementa o valor selecionado
Page Up and Page Down Optionally increase and decrease the value by a set amount (e.g. by 10 on a range from 0 to 100)

Possible effects on user agents and assistive technology 


Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative.


Examplo 1: Escala numérica simples

In the example below, a simple slider is used to select a value between 1 and 100. The current volume is 50. The application will programmatically update the value of aria-valuenow in response to user input.

<label for="fader">Volume</label>
<input type="range"
<output for="fader" id="volume">50</output>

The following code snippet allows you to return the output as it is updated by user input:

function outputUpdate(vol) { 
  document.querySelector('#volume').value = vol;

Examplo 2: Valores de texto

Sometimes, a slider is used to choose a value that is not, semantically, a number. In these cases, the aria-valuetext attribute is used to provide the appropriate text name for the currently selected value. In the example below, the slider is used to select a day of the week.

<label for="day-handle">Days</label>
<div class="day-slider">
  <div id="day-handle" class="day-slider-handle" role="slider" aria-labelledby="day-handle"

The code snippet below shows a function that responds to user input and updates the aria-valuenow and aria-valuetext attributes:

var dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var updateSlider = function (newValue) {
    var handle = document.getElementById("day-handle");
    handle.setAttribute("aria-valuenow", newValue.toString());
    handle.setAttribute("aria-valuetext", dayNames[newValue]);

Working Examples:


Atributos ARIA usados


TBD: Add support information for common UA and AT product combinations

Recursos Adicionais

Etiquetas do documento e colaboradores

 Colaboradores desta página: rener_bz
 Última atualização por: rener_bz,