Class: UI::ButtonGroupTextComponent

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

Overview

TextComponent - ViewComponent implementation

Displays text within a button group. Uses ButtonGroupTextBehavior module for shared styling logic.

Based on shadcn/ui ButtonGroup: ui.shadcn.com/docs/components/button-group

Examples:

Basic text

<%= render UI::ButtonGroupComponent.new do %>
  <%= render UI::TextComponent.new { "Label" } %>
  <%= render UI::ButtonComponent.new(variant: :outline) { "Button" } %>
<% end %>

Instance Method Summary collapse

Methods included from ButtonGroupTextBehavior

#text_classes, #text_html_attributes

Constructor Details

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

Returns a new instance of ButtonGroupTextComponent.

Parameters:

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



20
21
22
23
# File 'app/view_components/ui/button_group_text_component.rb', line 20

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

Instance Method Details

#callObject



25
26
27
28
29
# File 'app/view_components/ui/button_group_text_component.rb', line 25

def call
  tag.div(**text_html_attributes.deep_merge(@attributes)) do
    content
  end
end