Range slider component for continuous numeric value selection.
slider/1 is a CSS-only input[type=range] with semantic Tailwind tokens and
full WAI-ARIA attributes. form_slider/1 integrates it with Phoenix.HTML.FormField
and Ecto changesets, adding label, description, and error display.
No JavaScript is required — the browser handles all drag, click, and keyboard interaction natively.
Enhancements
marks— renders tick marks + labels below the track at specified valuesvertical— rotates the slider 90° for vertical orientationshow_value— renders a badge above the thumb showing the current value
Examples
<%!-- Basic slider --%>
<.slider value={50} phx-change="update_value" name="value" />
<%!-- With marks --%>
<.slider value={@speed} min={0} max={100} step={25}
marks={[%{value: 0, label: "Slow"}, %{value: 100, label: "Fast"}]}
phx-change="set_speed" name="speed" />
<%!-- Vertical orientation --%>
<.slider value={@vol} vertical={true} phx-change="set_vol" name="vol" />
<%!-- Show current value badge --%>
<.slider value={@size} min={8} max={72} show_value={true} phx-change="set_size" name="size" />
Summary
Functions
Renders a form-integrated slider with label, description, and changeset errors.
Renders a range slider input.
Functions
Renders a form-integrated slider with label, description, and changeset errors.
Attributes
field(Phoenix.HTML.FormField) (required) - APhoenix.HTML.FormFieldstruct.label(:string) - Text rendered in a<label>above the slider. Defaults tonil.description(:string) - Helper text rendered below the label. Defaults tonil.min(:integer) - Minimum allowed value. Defaults to0.max(:integer) - Maximum allowed value. Defaults to100.step(:integer) - Step increment between valid values. Defaults to1.marks(:list) - List of tick mark maps:[%{value: N, label: "text"}]. Defaults to[].vertical(:boolean) - Vertical orientation. Defaults tofalse.show_value(:boolean) - Show current value badge above thumb. Defaults tofalse.class(:string) - Additional CSS classes. Defaults tonil.- Global attributes are accepted. HTML attributes forwarded to the
<input>element. Supports all globals plus:["phx-change", "phx-blur", "phx-debounce", "disabled"].
Renders a range slider input.
When marks, vertical, or show_value are used the slider is wrapped in
a positioned <div> container. Otherwise a bare <input> is rendered
(backward-compatible with existing usage).
Attributes
value(:integer) - The current value of the slider. Defaults to0.min(:integer) - Minimum allowed value. Defaults to0.max(:integer) - Maximum allowed value. Defaults to100.step(:integer) - Step increment between valid values. Defaults to1.disabled(:boolean) - Whentrue, disables the slider. Defaults tofalse.marks(:list) - List of tick mark maps:[%{value: 0, label: "Min"}, %{value: 100, label: "Max"}]. Marks are positioned below the track at their corresponding percentage.Defaults to
[].vertical(:boolean) - Whentrue, renders the slider in vertical orientation (rotated 90°). Defaults tofalse.show_value(:boolean) - Whentrue, renders a badge above the thumb showing the current value. Defaults tofalse.class(:string) - Additional CSS classes. Defaults tonil.Global attributes are accepted. HTML attributes forwarded to the
<input>element. Supports all globals plus:["phx-change", "phx-blur", "name", "id"].