x
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
<!-- Select -->
<select name="fruits" id="fruits" class="input"><option value="Apple">Apple</option>
<option value="Banana">Banana</option>
<option value="Blueberry">Blueberry</option>
<option value="Grapes">Grapes</option>
<option value="Pineaple">Pineaple</option></select>
<!-- Select With Multiple -->
<select name="multiple_fruits[]" id="multiple_fruits" multiple="multiple" size="3" class="input"><option value="Apple">Apple</option>
<option value="Banana">Banana</option>
<option value="Blueberry">Blueberry</option>
<option value="Grapes">Grapes</option>
<option value="Pineaple">Pineaple</option></select>
<!-- Select With Groups -->
<select name="cars" id="cars" class="input"><optgroup label="American"><option value="Ford">Ford</option>
<option value="Chevrolet">Chevrolet</option>
<option value="Dodge">Dodge</option></optgroup><optgroup label="European"><option value="BMW">BMW</option>
<option value="Mercedes-Benz">Mercedes-Benz</option>
<option value="Volkswagen">Volkswagen</option></optgroup><optgroup label="Asian"><option value="Toyota">Toyota</option>
<option value="Honda">Honda</option>
<option value="Nissan">Nissan</option></optgroup></select>
<!-- Select With Separator -->
<select name="majors" id="majors" class="input">
<option value="">Select a major</option>
<hr>
<option value="arth">Art History</option>
<option value="finearts">Fine Arts</option>
<option value="gdes">Graphic Design</option>
<hr>
<option value="aeroeng">Aerospace Engineering</option>
<option value="biochemeng">Biochemical Engineering</option>
<option value="civileng">Civil Engineering</option>
</select>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<%# Select %>
<%= select_tag :fruits, options_for_select(["Apple", "Banana", "Blueberry", "Grapes", "Pineaple"]), class: "input" %>
<%# Select With Multiple %>
<%= select_tag :multiple_fruits, options_for_select(["Apple", "Banana", "Blueberry", "Grapes", "Pineaple"]), multiple: true, size: 3, class: "input" %>
<%# Select With Groups %>
<%= select_tag :cars, grouped_options_for_select({"American" => ["Ford", "Chevrolet", "Dodge"], "European" => ["BMW", "Mercedes-Benz", "Volkswagen"], "Asian" => ["Toyota", "Honda", "Nissan"]}), class: "input" %>
<%# Select With Separator %>
<select name="majors" id="majors" class="input">
<option value="">Select a major</option>
<hr>
<option value="arth">Art History</option>
<option value="finearts">Fine Arts</option>
<option value="gdes">Graphic Design</option>
<hr>
<option value="aeroeng">Aerospace Engineering</option>
<option value="biochemeng">Biochemical Engineering</option>
<option value="civileng">Civil Engineering</option>
</select>
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.