Tabs

Tabs

This tabs component works without JavaScript by using a combination of anchors, which point to the tabpanels, and CSS, that shows the correct tabpanel using :target. If JavaScript is enabled, the behavior will be enhanced and the anchors will be replaced using buttons. The implementation is roughly based on this Example of Tabs with Automative Activation on w3.org.

Information

Folder
src/components/patterns/tabs

Files

Schema
// src/components/patterns/tabs/schema.yaml

$schema: http://json-schema.org/draft-07/schema
$id: /patterns/tabs
additionalProperties: false
type: object
required:
  - tabs
  - content
properties:
  is_interactive:
    $ref: /patterns/tabs/tabs-list#/properties/is_interactive
  tabs:
    $ref: /patterns/tabs/tabs-list#/properties/tabs
  content:
    type: array
    items:
      type: object
      additionalProperties: false
      required:
        - content
        - id
      properties:
        content:
          type: string
          format: html
          description: patterns/*
        id:
          type: string
        is_selected:
          type: boolean
Mocks
// src/components/patterns/tabs/mocks.yaml

$ref: patterns/tabs/tabs-list#interactive
content:
  - content:
      $tpl: patterns/tabs/tabs-content
      $ref: patterns/tabs/tabs-content#graph
    id: tab-1
    is_selected: true
  - content:
      $tpl: patterns/tabs/tabs-content
      $ref: patterns/tabs/tabs-content#teasers
    id: tab-2
  - content:
      $tpl: patterns/tabs/tabs-content
      $ref: patterns/tabs/tabs-content#stats
    id: tab-3
Template
// src/components/patterns/tabs/tabs.html.twig

<div class="Tabs u-pageMainChild u-container js-Tabs" data-js="false">
  {% if heading %}
    <div class="Tabs-heading">
      {{ heading }}
    </div>
  {% endif %}
  {% include "@patterns/tabs/tabs-list/tabs-list.html.twig" with {
    is_interactive: is_interactive,
    tabs: tabs,
  } only %}
  <div class="Tabs-tabpanels">
    {% for item in content %}
      <div class="Tabs-tabpanel" role="tabpanel" tabindex="-1" id="{{ item.id }}" aria-labelledby="{{ item.id }}"{% if not item.is_selected %} hidden{% endif %}>
        {{ item.content|raw }}
      </div>
    {% endfor %}
  </div>
</div>

Variants

default
Open

So wird Ihre Spende eingesetzt

Jeder Beitrag zählt! Über 67% der Spenden fließen direkt in Kampagnen, die den Schutz unserer Umwelt vorantreiben. Weitere Mittel werden in Kommunikation, Werbung und Verwaltung investiert, um die Wirkung unserer Arbeit zu maximieren.

Mehr erfahren in unserem Jahresbericht
Spenden halbkreis
Initiative Transparente Zivilgesellschaft Deutscher Fundraising Verband

Vertrauen durch Transparenz

Greenpeace ist stolz darauf, Siegel wie das der "Initiative Transparente Zivilgesellschaft" zu tragen. Wir setzen auf volle Offenlegung unserer Finanzen, um Ihr Vertrauen zu stärken und unsere Arbeit so nachvollziehbar wie möglich zu gestalten.