Slider
Com rótulo
Faixa
import { Slider } from '@rivocode/ui'Quando usar
Escolha de valor numa faixa: desconto, prazo, tolerancia.
Só vale quando o número exato não importa. Se importa, o NumberField diz
mais e não pede pontaria: arrastar um pino até 37 e trabalho, digitar 37 não.
<Slider defaultValue={25} max={50} label="Desconto" showValue />
O label é o nome que o leitor de tela lê no pino, e não só o texto acima
dele: um pino sem rótulo visível é que precisa de thumbLabel.
format escreve o número do showValue e o que o leitor de tela anuncia: o
nome de um formatador da casa, ou uma função sua para a unidade que só esta tela
tem.
<Slider defaultValue={30} max={90} label="Prazo" showValue format={(dias) => `${dias} dias`} />
Com dois valores, vira faixa de dois pinos, e cada pino precisa do próprio nome, senao o leitor de tela anuncia dois controles iguais:
<Slider
defaultValue={[20, 60]}
label="Faixa de valor"
showValue
thumbLabel={['Valor minimo', 'Valor maximo']}
/>
No React Native
Traduz: o @rivocode/ui-native exporta Slider - anda por gesto e responde às ações do leitor de tela; um valor só, e label obrigatório. A API não é a mesma do web (no nativo tudo é controlado), e a tabela de paridade diz o que muda peça a peça.
API
| Prop | Tipo |
|---|---|
classNames0.5.0Classe por parte: `label`, `value`, `control`, `track`, `indicator`, `thumb`. | Partial<Record<"control""indicator""label""thumb""track""value", string>> |
defaultValue0.4.0The uncontrolled value of the slider when it's initially rendered. | number | readonly number[] |
disabled0.4.0Whether the slider should ignore user interaction. | boolean |
form0.4.0Identifies the form that owns the slider inputs. | string |
format0.4.0Como o numero e escrito: nome de formatador da casa ou funcao propria, o mesmo vocabulario do eixo do grafico. | Format |
label0.4.0Texto acima do controle, e o nome que o leitor de tela le no pino. | ReactNode |
largeStep0.4.0The granularity with which the slider can step through values when using Page Up/Page Down or Shift + Arrow Up/Arrow Down. | number |
locale0.4.0The locale used by `Intl.NumberFormat` when formatting the value. | LocalesArgument |
max0.4.0The maximum allowed value of the slider. | number |
min0.4.0The minimum allowed value of the slider. | number |
minStepsBetweenValues0.4.0The minimum steps between values in a range slider. | number |
name0.4.0Identifies the field when a form is submitted. | string |
numberFormat0.5.0As opcoes do `Intl.NumberFormat`, para quem precisa delas. | NumberFormatOptions |
onValueChange0.4.0Callback function that is fired when the slider's value changed. | ((value: number | readonly number[], eventDetails: SliderRootChangeEventDetails) => void) |
onValueCommitted0.4.0Callback function that is fired when a value change is committed. | ((value: number | readonly number[], eventDetails: SliderRootCommitEventDetails) => void) |
orientation0.4.0The component orientation. | Orientation |
render0.4.0Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ComponentRenderFn<HTMLProps, SliderRootState>ReactElement<unknown, stringJSXElementConstructor<any>> |
showValue0.4.0Mostra o valor ao lado do rotulo. | boolean |
step0.4.0The granularity with which the slider can step through values. | number |
thumbAlignment0.4.0How the thumb(s) are aligned relative to `Slider.Control` when the value is at `min` or `max`: - `center`: The center of the thumb is aligned with the control edge - `edge`: The thumb is inset within the control such that its edge is aligned with the control edge - `edge-client-only`: Same as `edge` but renders after React hydration on the client, reducing bundle size in return | "center""edge""edge-client-only" |
thumbCollisionBehavior0.4.0Controls how thumbs behave when they collide during pointer interactions. | "none""push""swap" |
thumbLabel0.4.0O que o leitor de tela chama o pino, no lugar do `label`. | string | string[] |
value0.4.0The value of the slider. | number | readonly number[] |
Além destas, a peça aceita className, style, id e children, repassados ao elemento de baixo.