Labels provide a useful description for various kinds of inputs.
Labels are used to provide text descriptions for form inputs. They can be used with any form input component.
Labels can be used with form inputs to provide a description for the input. Here's an example with a checkbox.
Many of our input components include the LabelableComponent
concern,
which provides built-in label functionality without needing separate label
components. This makes your code cleaner and ensures proper semantic
markup.
The TextInput , Select , Checkbox , and Toggle components include this functionality.
Start Labels (appear before the input)
Start Labels (appear before the input)
.my-2.flex.flex-col.gap-4
%p.font-medium.mb-2 Start Labels (appear before the input)
= daisy_text_input(name: "username", id: "username", start: "Username:")
.mt-4
= daisy_select(name: "country", id: "country", start: "Country:", options: ["USA", "Canada", "UK"])
End labels appear after the input. They are especially useful for checkboxes
and toggles, but can be used with any input component that includes the
LabelableComponent
concern.
Floating labels appear above the input when it has focus or contains a value. This provides a clean, modern look while maintaining good UX.
For more complex labels, you can use the slot API to provide custom content to your labels. This is useful when you need to add HTML or other components within your label.
.my-2.flex.flex-col.gap-4
= daisy_text_input(name: "password", id: "password", type: "password") do |input|
- input.with_start do
Password
%span.text-error.ml-1 *
.mt-4
= daisy_checkbox(name: "newsletter", id: "newsletter") do |cb|
- cb.with_end do
Subscribe to newsletter
%span.text-xs.text-gray-500.ml-1 (Optional)
We've also extended the standard Rails FormBuilder with custom helper methods for rendering Daisy Inputs with labels.
Create virtual credit / debit cards to keep your real info safe.
Get $5 when you sign up — free to start!
Everything you need to grow your business with confidence!
CRM, Lead Generation, Project Management, Contracts, Online Payments, and more!
The ads above are affiliate links to products I regularly use and highly
recommend.
I may receive a commission if you decide to purchase.