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
<!-- Input With Default Label -->
<div class="">
<label class="block mb-2.5 text-sm font-medium text-heading" for="person_first_name">First name</label>
<input class="bg-neutral-secondary-medium border border-default-medium text-heading rounded-base focus:ring-brand focus:border-brand block w-full shadow-xs placeholder:text-body px-3 py-2.5 text-sm" type="text" value="John" name="person[first_name]" id="person_first_name" />
</div>
<!-- Input With Specified Label Text -->
<div class="">
<label class="block mb-2.5 text-sm font-medium text-heading" for="person_first_name">Custom label text</label>
<input class="bg-neutral-secondary-medium border border-default-medium text-heading rounded-base focus:ring-brand focus:border-brand block w-full shadow-xs placeholder:text-body px-3 py-2.5 text-sm" type="text" value="John" name="person[first_name]" id="person_first_name" />
</div>
<!-- Input With Specified Label Options -->
<div class="">
<label class="custom-label-class" for="person_first_name">First name</label>
<input class="bg-neutral-secondary-medium border border-default-medium text-heading rounded-base focus:ring-brand focus:border-brand block w-full shadow-xs placeholder:text-body px-3 py-2.5 text-sm" type="text" value="John" name="person[first_name]" id="person_first_name" />
</div>
<!-- Input With Custom Label -->
<div class="">
This is a custom label replacing the entire label
<input class="bg-neutral-secondary-medium border border-default-medium text-heading rounded-base focus:ring-brand focus:border-brand block w-full shadow-xs placeholder:text-body px-3 py-2.5 text-sm" type="text" value="John" name="person[first_name]" id="person_first_name" />
</div>
<!-- Input With Placeholder -->
<div class="">
<label class="block mb-2.5 text-sm font-medium text-heading" for="person_first_name">First name</label>
<input class="bg-neutral-secondary-medium border border-default-medium text-heading rounded-base focus:ring-brand focus:border-brand block w-full shadow-xs placeholder:text-body px-3 py-2.5 text-sm" placeholder="Enter your first name" type="text" name="person[first_name]" id="person_first_name" />
</div>
<!-- Kitchen Sink -->
<div data-controller="form-field" class="mb-4 w-full">
<label class="mb-2 font-medium" for="person_first_name">First name</label>
<input class="bg-neutral-secondary-medium border border-default-medium text-fg-disabled rounded-base focus:ring-brand focus:border-brand block w-full shadow-xs cursor-not-allowed placeholder:text-fg-disabled px-3.5 py-3 text-base" disabled="disabled" aria-describedby="person_first_name_hint" placeholder="Enter your first name" type="text" name="person[first_name]" id="person_first_name" />
<p class="mt-2.5 text-sm text-body" id="name-helper-text">What should we call you?</p>
</div>
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
# Input With Default Label
render(
Flowbite::InputField::Text.new(
attribute: :first_name,
form: form
)
)
# Input With Specified Label Text
render(
Flowbite::InputField::Text.new(
attribute: :first_name,
form: form,
label: {content: "Custom label text"}
)
)
# Input With Specified Label Options
render(
Flowbite::InputField::Text.new(
attribute: :first_name,
form: form,
label: {options: {class: "custom-label-class"}}
)
)
# Input With Custom Label
render(
Flowbite::InputField::Text.new(
attribute: :first_name,
form: form
)
) do |input|
input.with_label do
"This is a custom label replacing the entire label"
end
end
# Input With Placeholder
person.first_name = nil
render(
Flowbite::InputField::Text.new(
attribute: :first_name,
form: form,
input: {options: {placeholder: "Enter your first name"}}
)
)
# Kitchen Sink
person.first_name = nil
render(
Flowbite::InputField::Text.new(
attribute: :first_name,
class: ["mb-4", "w-full"],
disabled: true,
form: form,
hint: {
content: "What should we call you?",
options: {id: "name-helper-text"}
},
input: {
options: {placeholder: "Enter your first name"}
},
label: {
content: "First name",
options: {class: ["mb-2", "font-medium"]}
},
options: {data: {controller: "form-field"}},
size: :lg
)
)