Class: UI::FieldGroupComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
FieldGroupBehavior
Defined in:
app/view_components/ui/field_group_component.rb

Overview

FieldGroupComponent - ViewComponent implementation

Layout wrapper that stacks Field components. Uses FieldGroupBehavior concern for shared styling logic.

Examples:

Basic usage

<%= render UI::FieldGroupComponent.new do %>
  <%= render UI::FieldComponent.new do %>
    Field 1
  <% end %>
  <%= render UI::FieldComponent.new do %>
    Field 2
  <% end %>
<% end %>

Instance Method Summary collapse

Methods included from FieldGroupBehavior

#field_group_classes, #field_group_html_attributes

Constructor Details

#initialize(classes: "", **attributes) ⇒ FieldGroupComponent

Returns a new instance of FieldGroupComponent.

Parameters:

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



22
23
24
25
# File 'app/view_components/ui/field_group_component.rb', line 22

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

Instance Method Details

#callObject



27
28
29
30
31
# File 'app/view_components/ui/field_group_component.rb', line 27

def call
   :div, **field_group_html_attributes do
    content
  end
end