Put a RulerSliderLabel and a RulerSliderValue in the header; the label names the slider, and a press on the value resets it.
straighten-ruler.tsx
RulerSlider
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | — | |
| default | number | — | |
| on | — | A value change, from a drag, a flick, a key, a reset, or Escape (cancel). | |
| on | — | The value at the end of a drag (after the flick), a key press, or a reset. | |
| on | — | true from the press until a flick stops: a host can show a grid while the ruler moves. | |
| min | number | -45 | Default -45. |
| max | number | 45 | Default 45. |
| step | number | 1 | The value grid and the arrow-key step. Default 1. |
| large | number | — | Shift + arrow and Page Up or Down. Default 10 steps. |
| tick | number | — | The value of one tick (6px). Default: step. |
| major | number | 5 | A major (long) tick each this many ticks, counted from 0. Default 5. |
| origin | number | "center" | "start" | "center" | The value with the dot, where a drag holds for 6px: center (0, kept inside the range), a number, or start (no dot; the span grows from min). Default center. |
| reset | number | — | The value of a reset. Default: defaultValue, else the origin. |
| labels | boolean | ((value: number) => string) | — | Numbers on the ticks: true (the formatted value), or a function. Not on vertical. The arc is made for up to 250 ticks: past half a turn of its circle the ticks overlap. |
| label | number | — | A label each this many ticks. Default majorEvery × 2. |
| variant | "arc""straight""vertical" | "straight" | straight (default), arc (a curved ruler), or vertical (higher values up). |
| size | "default""lg""sm" | "default" | |
| format | NumberFormatOptions | — | The number format of the value, the labels, and aria-valuetext. |
| locale | LocalesArgument | — | |
| disabled | boolean | false | |
| read | boolean | false | The value shows and follows a controlled value, but takes no input. |
| invalid | boolean | — | Shown as invalid (an invalid Field around it does the same). |
| name | string | — | |
| form | string | — | |
| aria-label | string | — | The name of the slider when there is no RulerSliderLabel. |
| get | — | The spoken value. Default: the formatted value. | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
RulerSliderLabel
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
RulerSliderValue
<button>| Prop | Type | Default | Description |
|---|---|---|---|
| children | — | The text: the formatted value by default. Return a unit around it ("5600 K"). | |
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. |
| Arrow keys | Changes the value by one step. |
|---|---|
| Shiftarrow keysorPage UporPage Down | Changes the value by largeStep. |
| HomeorEnd | Goes to the minimum or the maximum. |
| DeleteorBackspace | Resets the value. |
| Escape | During a drag: cancels the drag and restores the value. |
- SliderPick Slider to jump to a point on a fixed track, or to pick a range with two thumbs.
- Image CropperPick the part of a picture to keep: 8 handles or a fixed circle, zoom, straighten, turns, flips, aspect presets, and full keyboard support.
- FieldPuts a label, a control, and one line of help or an error together. FieldSet groups several controls under one legend.
Built with
Installs with Ruler Slider











