Class: DaisyUI::Label

Inherits:
Base
  • Object
show all
Defined in:
lib/daisy_ui/label.rb

Overview

Label component for wrapping inputs, selects, or creating floating labels

Examples:

Floating label

DaisyUI::Label.new(:floating) do
  input(type: "text", placeholder: "Email", class: "input input-md")
  span { "Your Email" }
end

Input wrapper with label

DaisyUI::Label.new(:input) do |label|
  label.text("https://")
  input(type: "text", placeholder: "URL")
end

Select wrapper with label

DaisyUI::Label.new(:select) do |label|
  label.text("Type")
  select do
    option { "Personal" }
    option { "Business" }
  end
end

Constant Summary

Constants inherited from Base

Base::BOOLS, Base::COLOR_MODIFIERS

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize, register_modifiers

Constructor Details

This class inherits a constructor from DaisyUI::Base

Instance Method Details

#text(content = nil, **options) ⇒ Object

Renders label text for input/select wrappers For floating labels, use a plain span instead

Examples:

label.text("Username")
label.text { "Email Address" }
label.text("https://", class: "custom-class")


66
67
68
69
70
# File 'lib/daisy_ui/label.rb', line 66

def text(content = nil, **options)
  span(class: component_classes("label", options:), **options) do
    content || yield
  end
end

#view_templateObject



55
56
57
# File 'lib/daisy_ui/label.rb', line 55

def view_template(&)
  label(class: classes, **attributes, &)
end