Module: UI::ButtonGroupBehavior

Included in:
ButtonGroup, ButtonGroupComponent
Defined in:
app/behaviors/ui/button_group_behavior.rb

Overview

ButtonGroupBehavior

Shared behavior for ButtonGroup component across ERB, ViewComponent, and Phlex implementations. This module provides consistent styling and HTML attribute generation.

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

Instance Method Summary collapse

Instance Method Details

#button_group_classesObject

Returns combined CSS classes for the button group



23
24
25
26
27
28
29
30
# File 'app/behaviors/ui/button_group_behavior.rb', line 23

def button_group_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  TailwindMerge::Merger.new.merge([
    button_group_base_classes,
    button_group_orientation_classes,
    classes_value
  ].compact.join(" "))
end

#button_group_html_attributesObject

Returns HTML attributes for the button group container



11
12
13
14
15
16
17
18
19
20
# File 'app/behaviors/ui/button_group_behavior.rb', line 11

def button_group_html_attributes
  {
    role: "group",
    data: {
      slot: "button-group",
      orientation: @orientation
    },
    class: button_group_classes
  }
end