Class: Primer::TabContainerComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/tab_container_component.rb

Overview

Use TabContainer to create tabbed content with keyboard support. This component does not add any styles. It only provides the tab functionality. If you want styled Tabs you can look at <%= link_to_component(Primer::TabNavComponent) %>.

This component requires javascript.

Constant Summary

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

Primer::TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(**system_arguments) ⇒ TabContainerComponent

Returns a new instance of TabContainerComponent.

Examples:

Default

<%= render(Primer::TabContainerComponent.new)  do %>
  <div role="tablist">
    <button type="button" role="tab" aria-selected="true">Tab one</button>
    <button type="button" role="tab" tabindex="-1">Tab two</button>
    <button type="button" role="tab" tabindex="-1">Tab three</button>
  </div>
  <div role="tabpanel">
    Panel 1
  </div>
  <div role="tabpanel" hidden>
    Panel 2
  </div>
  <div role="tabpanel" hidden>
    Panel 3
  </div>
<% end %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



28
29
30
31
# File 'app/components/primer/tab_container_component.rb', line 28

def initialize(**system_arguments)
  @system_arguments = system_arguments
  @system_arguments[:tag] = "tab-container"
end

Instance Method Details

#callObject



33
34
35
# File 'app/components/primer/tab_container_component.rb', line 33

def call
  render(Primer::BaseComponent.new(**@system_arguments)) { content }
end

#render?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/components/primer/tab_container_component.rb', line 37

def render?
  content.present?
end