Class: UI::FieldLegend

Inherits:
Phlex::HTML
  • Object
show all
Includes:
FieldLegendBehavior
Defined in:
app/components/ui/field_legend.rb

Overview

Legend - Phlex implementation

Legend element for FieldSet with variant support. Uses FieldLegendBehavior concern for shared styling logic.

Examples:

Basic usage

render UI::Legend.new { "Personal Information" }

With variant

render UI::Legend.new(variant: "label") { "Settings" }

Instance Method Summary collapse

Methods included from FieldLegendBehavior

#field_legend_classes, #field_legend_html_attributes

Constructor Details

#initialize(variant: "legend", classes: "", **attributes) ⇒ FieldLegend

Returns a new instance of FieldLegend.

Parameters:

  • variant (String) (defaults to: "legend")

    Style variant: “legend” or “label”

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



19
20
21
22
23
# File 'app/components/ui/field_legend.rb', line 19

def initialize(variant: "legend", classes: "", **attributes)
  @variant = variant
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



25
26
27
28
29
# File 'app/components/ui/field_legend.rb', line 25

def view_template(&block)
  legend(**field_legend_html_attributes) do
    yield if block_given?
  end
end