x
1
2
3
4
5
6
7
8
9
10
<!-- Range -->
<input type="range" name="range_field" id="range_field" value="2" min="0" max="10" class="range i-full" />
<!-- Range With Tick Marks -->
<input type="range" name="range_with_tick_marks" id="range_with_tick_marks" value="25" step="25" list="tickmarks" class="range i-full" />
<datalist id="tickmarks"><option value="0">0</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="75">75</option>
<option value="100">100</option></datalist>
1
2
3
4
5
6
<%# Range %>
<%= range_field_tag "range_field", 2, min: 0, max: 10, class: "range i-full" %>
<%# Range With Tick Marks %>
<%= range_field_tag "range_with_tick_marks", 25, step: 25, list: "tickmarks", class: "range i-full" %>
<%= tag.datalist options_for_select(["0", "25", "50", "75", "100"]), id: "tickmarks" %>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.input {
appearance: none;
background-color: var(--input-background, var(--color-bg));
border: 1px solid var(--input-border-color, var(--color-border));
border-radius: var(--input-radius, var(--rounded-md));
font-size: var(--input-font-size, var(--text-sm));
inline-size: var(--input-inline-size, var(--size-full));
min-block-size: var(--input-block-size, var(--size-10));
padding: var(--input-padding, 0.5rem 0.75rem);
option {
padding-block: 2px;
}
&:is(textarea[rows=auto]) {
field-sizing: content;
max-block-size: calc(10lh + var(--size-6));
min-block-size: calc(3lh + var(--size-6));
}
&:is(select):not([multiple], [size]) {
background-image: url("select-arrow.svg");
background-position: center right var(--size-2);
background-repeat: no-repeat;
background-size: var(--size-4) auto;
}
&::file-selector-button {
font-weight: var(--font-medium);
margin-inline-end: var(--size-2);
}
&:user-invalid {
border-color: var(--color-negative);
}
&:user-invalid ~ .invalid-feedback {
display: flex;
}
&:disabled {
cursor: not-allowed;
opacity: var(--opacity-50);
}
}
/* Hide invalid feedback by default */
.invalid-feedback {
display: none;
}
/* Containers that act like (and contain) inputs */
.input--actor {
input {
border: 0; inline-size: 100%; outline: 0;
}
img:not([class]) {
filter: var(--input-icon-color, var(--color-filter-text));
}
&:focus-within {
outline: var(--input-outline-size, 2px) solid var(--color-selected-dark);
outline-offset: var(--border-2);
}
}
/* Checkbox, radio, and range */
.checkbox, .radio {
accent-color: var(--color-primary); transform: scale(1.15);
}
.range {
accent-color: var(--color-primary);
}
/* Styles that are shared between components */
:is(.input, .checkbox, .radio, .range) {
&:focus-visible {
outline: var(--input-outline-size, 2px) solid var(--color-selected-dark);
outline-offset: var(--border-2);
}
.field_with_errors & {
border-color: var(--color-negative);
}
}
Java Script is not required or multiple files are needed, check the notes.