Class: NitroKit::Label

Inherits:
Component
  • Object
show all
Defined in:
app/components/nitro_kit/label.rb

Instance Attribute Summary collapse

Attributes inherited from Component

#attrs

Instance Method Summary collapse

Methods inherited from Component

#builder, from_template

Constructor Details

#initialize(text = nil, **attrs) ⇒ Label

Returns a new instance of Label.



5
6
7
8
9
10
11
12
13
# File 'app/components/nitro_kit/label.rb', line 5

def initialize(text = nil, **attrs)
  @text = text

  super(
    attrs,
    class: "text-sm font-medium select-none",
    data: { slot: "label" }
  )
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



15
16
17
# File 'app/components/nitro_kit/label.rb', line 15

def text
  @text
end

Instance Method Details

#view_template(&block) ⇒ Object



17
18
19
20
21
# File 'app/components/nitro_kit/label.rb', line 17

def view_template(&block)
  label(**attrs) do
    text_or_block(text, &block)
  end
end