Class: NitroKit::ButtonGroup

Inherits:
Component
  • Object
show all
Defined in:
app/components/nitro_kit/button_group.rb

Instance Attribute Summary

Attributes inherited from Component

#attrs

Instance Method Summary collapse

Methods inherited from Component

#builder, from_template

Constructor Details

#initialize(**attrs) ⇒ ButtonGroup

Returns a new instance of ButtonGroup.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/components/nitro_kit/button_group.rb', line 5

def initialize(**attrs)
  super(
    attrs,
    class: [
      "flex -space-x-px isolate",
      # Remove rounded corners from middle buttons
      "[&>*:not(:first-child):not(:last-child)]:rounded-none [&>*:first-child:not(:last-child)]:rounded-r-none [&>*:last-child:not(:first-child)]:rounded-l-none",
      # Put focused button on top
      "[&>*]:focus:z-10"
    ]
  )
end

Instance Method Details

#view_templateObject



18
19
20
21
22
# File 'app/components/nitro_kit/button_group.rb', line 18

def view_template
  div(**attrs) do
    yield
  end
end