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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!-- Text Field -->
<input type="text" name="text_field" id="text_field" class="input" />
<!-- Email Field -->
<input type="email" name="email_field" id="email_field" class="input" />
<!-- Search Field -->
<input type="search" name="search_field" id="search_field" class="input" />
<!-- Integer Field -->
<input type="number" name="integer_field" id="integer_field" min="0" max="30" inputmode="numeric" class="input" />
<!-- Decimal Field -->
<input type="number" name="decimal_field" id="decimal_field" step="0.01" inputmode="decimal" class="input" />
<!-- Date Field -->
<input type="date" name="date_field" id="date_field" class="input" />
<!-- Datetime Field -->
<input class="input" type="datetime-local" name="datetime_field[]" id="datetime_field_" />
<!-- File Field -->
<input type="file" name="file_field" id="file_field" class="input" />
<!-- Pattern Field -->
<input type="text" name="pattern_field" id="pattern_field" placeholder="000.000.000-00" pattern="\d{3}\.\d{3}\.\d{3}-\d{2}" maxlength="14" class="input" />
<div class="invalid-feedback text-sm text-negative mbs-1">Please provide a valid CPF.</div>
<!-- Autocomplete Field -->
<input type="text" name="autocomplete_field" id="autocomplete_field" list="ice_cream_flavors" class="input" />
<datalist id="ice_cream_flavors"><option value="Chocolate">Chocolate</option>
<option value="Coconut">Coconut</option>
<option value="Mint">Mint</option>
<option value="Strawberry">Strawberry</option>
<option value="Vanilla">Vanilla</option></datalist>
<!-- Color Field -->
<input type="color" name="color_field" id="color_field" list="predefined colors" class="input" />
<datalist id="predefined colors"><option value="#ede9fe">#ede9fe</option>
<option value="#ddd6fe">#ddd6fe</option>
<option value="#c4b5fd">#c4b5fd</option>
<option value="#a78bfa">#a78bfa</option>
<option value="#8b5cf6">#8b5cf6</option></datalist>
<!-- Actor Field -->
<label class="input input--actor flex items-center gap">
<img aria-hidden="true" src="/assets/search-fe0b57ec.svg" width="16" height="16" />
<input type="text" name="actor_field" id="actor_field" data-action="input->command#filter" />
</label>
<!-- Disabled Field -->
<input type="text" name="disabled_field" id="disabled_field" disabled="disabled" class="input" />
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
<%# Text Field %>
<%= text_field_tag "text_field", nil, class: "input" %>
<%# Email Field %>
<%= email_field_tag "email_field", nil, class: "input" %>
<%# Search Field %>
<%= search_field_tag "search_field", nil, class: "input" %>
<%# Integer Field %>
<%= number_field_tag "integer_field", nil, min: 0, max: 30, inputmode: :numeric, class: "input" %>
<%# Decimal Field %>
<%= number_field_tag "decimal_field", nil, step: "0.01", inputmode: :decimal, class: "input" %>
<%# Date Field %>
<%= date_field_tag "date_field", nil, class: "input" %>
<%# Datetime Field %>
<%= datetime_field "datetime_field", nil, class: "input" %>
<%# File Field %>
<%= file_field_tag "file_field", class: "input" %>
<%# Pattern Field %>
<%= text_field_tag "pattern_field", nil, placeholder: "000.000.000-00", pattern: '\d{3}\.\d{3}\.\d{3}-\d{2}', maxlength: "14", class: "input" %>
<div class="invalid-feedback text-sm text-negative mbs-1">Please provide a valid CPF.</div>
<%# Autocomplete Field %>
<%= text_field_tag "autocomplete_field", nil, list: "ice_cream_flavors", class: "input" %>
<%= tag.datalist options_for_select(["Chocolate", "Coconut", "Mint", "Strawberry", "Vanilla"]), id: "ice_cream_flavors" %>
<%# Color Field %>
<%= color_field_tag "color_field", nil, list: "predefined colors", class: "input" %>
<%= tag.datalist options_for_select(["#ede9fe", "#ddd6fe", "#c4b5fd", "#a78bfa", "#8b5cf6"]), id: "predefined colors" %>
<%# Actor Field %>
<label class="input input--actor flex items-center gap">
<%= image_tag "search.svg", size: 16, aria: { hidden: true } %>
<%= text_field_tag "actor_field", nil, data: { action: "input->command#filter" } %>
</label>
<%# Disabled Field %>
<%= text_field_tag "disabled_field", nil, disabled: true, class: "input" %>
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.