Class: DaisyUI::Card::Title

Inherits:
BaseComponent show all
Defined in:
app/components/daisy_ui/data_display/card/title.rb

Overview

Title component for the card, handling the title display

Examples:

Basic usage

<%= render(CardComponent.new) do |component| %>
  <% component.with_body do |body| %>
    <% body.with_title { "Card Title" } %>
  <% end %>
<% end %>

With custom tag

<%= render(CardComponent.new) do |component| %>
  <% component.with_body do |body| %>
    <% body.with_title(tag_name: :h1) { "Large Title" } %>
  <% end %>
<% end %>

With text parameter

<%= render(CardComponent.new) do |component| %>
  <% component.with_body do |body| %>
    <% body.with_title("Simple Title") %>
  <% end %>
<% end %>

Instance Method Summary collapse

Constructor Details

#initialize(text = nil, tag_name: :h2, **system_arguments) ⇒ Title



31
32
33
34
35
# File 'app/components/daisy_ui/data_display/card/title.rb', line 31

def initialize(text = nil, tag_name: :h2, **system_arguments)
  @text = text
  @tag_name = tag_name
  super(**system_arguments)
end

Instance Method Details

#callObject



37
38
39
40
41
# File 'app/components/daisy_ui/data_display/card/title.rb', line 37

def call
  (@tag_name, **html_attributes) do
    content || @text
  end
end