Class: UI::TabsListComponent

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

Overview

TabsList component (ViewComponent) Container for tab trigger buttons

Examples:

Basic usage

<%= render UI::TabsListComponent.new do %>
  <%= render UI::TabsTriggerComponent.new(value: "tab1") { "Tab 1" } %>
  <%= render UI::TabsTriggerComponent.new(value: "tab2") { "Tab 2" } %>
<% end %>

Instance Method Summary collapse

Methods included from TabsListBehavior

#list_html_attributes

Constructor Details

#initialize(orientation: "horizontal", classes: "", attributes: {}) ⇒ TabsListComponent

Returns a new instance of TabsListComponent.

Parameters:

  • orientation (String) (defaults to: "horizontal")

    “horizontal” or “vertical”

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

    additional CSS classes

  • attributes (Hash) (defaults to: {})

    additional HTML attributes



17
18
19
20
21
# File 'app/view_components/ui/tabs_list_component.rb', line 17

def initialize(orientation: "horizontal", classes: "", attributes: {})
  @orientation = orientation
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



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

def call
  attrs = list_html_attributes

   :div, **attrs.merge(@attributes) do
    content
  end
end