Soracom

Design System
  1. Home
  2. Design system
  3. Elements
  4. Tabs

Tabs

Displays a tab bar style list of menu items and contents

ds-tabs works inside ds-group containers, and adjusts appropriately if it is the first-child of the group (with no group title), follows a group title, or inline with mixed content

Options

Basic usage

ds-tabs can be implemented as pure decoration by using the following format. When used like this, any interactive highlighting of the current selected tab, or switching of the tab contents needs to be implemented by another means (i.e. javascript).

Using this method, the currently selected tab can be highlighted by adding --selected to the list item.

When used in this format, the contents of the <li> can be any element such as a <span>, <div>, <p> or <a>.

Basic non-interactive usage

html
Copy

It is also possible to use this format without the role attributes, but this is not recommended as it will reduce accessibility and prevent some styling options.

Basic non-interactive usage

html Deprecated
Copy

Interactive tabs

Using the following html structure, ds-tabs will also handle the interactive highlighting of the current selected tab and switching of the tab content.

SDS currently supports a maximum of 16 interactive tabs. Content for each tab is contained inside an html element with role="tabpanel" and a counter __X where X is 1 to 16. This container does not assume a specific layout type for it’s contents, so adding ds-rows may be required.

Input placement at root

  • Each input on a page requires a unique id with the same value used in the matching <label for=""> element.
  • All input elements within the tab must use the same name attribute unique to that ds-tabs instance.
  • Each tab requires a matching radio input
  • The order of the inputs must match the order of the li elements.

Input inside the ds-tabs container

html
Copy

It is also possible to use this format without the role attributes, but this is not recommended as it will reduce accessibility and prevent some styling options. Content for each tab is contained inside an html element with the classname __content --X where X is 1 to 16. This container does not assume a specific layout type for it’s contents, so adding ds-rows may be required.

Input inside the ds-tabs container

html Deprecated
Copy

Input placement inside tab

  • Each tab must contain a label element, which contains the input and label text
  • All input elements must use the same name attribute unique to that ds-tabs instance.

Input inside the tab

html
Copy

Input inside the tab

html Deprecated
Copy

Disabled tabs

A non-interactive tab can be disabled by setting the tab to --disabled.

Basic non-interactive usage

html
Copy

Basic non-interactive usage

html Deprecated
Copy

An interactive tab can be disabled by setting the radio input to disabled.

Input placement at root

Input inside the ds-tabs container

html
Copy

Input inside the ds-tabs container

html Deprecated
Copy

Input placement inside tab

Input inside the tab

html
Copy

Input inside the tab

html Deprecated
Copy

Sizing

Horizontal tabs sizing

html Deprecated
Copy

Vertical tabs sizing

html Deprecated
Copy

Tab bar

Tab wrapping

By default, tabs will wrap to a new row if they do not fit on a single row. To keep all tabs on a single row and allow the label text to wrap instead use --no-wrap. Note: At screen sizes less than 680px tabs will wrap to a new row if required.

Example with simple content

html Deprecated
Copy

Sticky tab bar

The tab bar can be made sticky by adding the class --sticky. The offset position can be controlled by setting an offset amount like --x where x is 0–180 in increments of 10, for example --60

html
Copy

Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Nullam quis risus eget urna mollis ornare vel eu leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae elit libero, a pharetra augue. Nullam quis risus eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed consectetur. Nulla vitae elit libero, a pharetra augue. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Nullam quis risus eget urna mollis ornare vel eu leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae elit libero, a pharetra augue. Nullam quis risus eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed consectetur. Nulla vitae elit libero, a pharetra augue. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Nullam quis risus eget urna mollis ornare vel eu leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae elit libero, a pharetra augue. Nullam quis risus eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed consectetur. Nulla vitae elit libero, a pharetra augue. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Content panels

Content panel indent

By default all tab content is indented. You can change indenting on all tab content by using the following classes on the ds-tabs container:

html
Copy

Additionally, you can control indenting of individual content panels by using the following classes on the __content element. These classes will override the classes set on the parent ds-tabs container.

html
Copy

Example --no-indent for all content except the first tab

html
Copy

Content panel height

By default ds-tabs will be a fixed height equal to the height of the largest content panel. To allow the height to change based on the height of the currently visible panel, use --adjust-height.

html
Copy

Styles

Custom styles exist for specific use cases.

Panel style

Panel style provides additional styling to the container, plus does not by default indent the tab contents. Individual tab contents can be indented using the class __content --indented.

Example with mixed content

html
Copy

Vertical style

Non-interactive vertical tabs

html
Copy

Interactive vertical tabs

html
Copy

Vertical style can be combined with other options above including panel style and use within groups.

Interactive vertical tabs with panel style

html
Copy

Examples

Vertical style combined with Panel style

html
Copy

Vertical style within a group

html
Copy

Inside group

ds-tabs can be implemented inside a ds-group container:

Interactive tabs example with mixed content

html
Copy

Vertical style interactive with inputs at root

html
Copy

Manifest

The component manifest describes this component's API — its modifiers, structure, data attributes, CSS custom properties, accessibility notes, and example markup. It is consumed by tooling such as AI assistants and code generators.

Latest version: https://assets.soracom.io/sds/latest/ds-tabs/index.mjs

index.mjs
Copy