TabStrip

Strip of tab buttons
One Two Three
Demo: TabStrip with default TabButton instances

Overview

A row or column of tab buttons, typically as part of a Tabs or similar component. TabStrip is responsible for positioning the tab buttons, handling keyboard navigation, and supporting accessibility. TabStrip is provided for cases where you want to construct your own tabbed UI beyond what's possible with Tabs.

TabStrip relies upon the tab buttons it contains to provide an appropriate visual appearance. A generic instance of TabStrip that uses plain <button> instances for tab buttons might look like this:

Demo: Generic TabStrip with plain buttons

For a typical tabbed button appearance, you can use instances of TabButton inside the TabStrip, as shown in the first demo above.

The TabStrip class is registered as element <elix-tab-strip>.

Keyboard support

TabStrip provides some additional keyboard support to make it easier for your users to switch tabs:

  • If one tab in the strip has the keyboard focus, you can press Left/Right (in horizontal orientation) or Up/Down (in vertical orientation) to select the previous/next tab.
  • If you move the keyboard focus to an unselected tab, you can press Space or Enter to select that tab.

See also

TabButton
Generic tab button with a text label
Tabs
Basic tabs structure for navigation and configuration

API

Ancestry: TabStrip → ReactiveElement → HTMLElement

Built with mixins AriaListMixin, AttributeMarshallingMixin, DirectionSelectionMixin, KeyboardDirectionMixin, KeyboardMixin, LanguageDirectionMixin, ReactiveMixin, ShadowTemplateMixin, SingleSelectionMixin, SlotItemsMixin, and TapSelectionMixin.

This element is used to fill a role in Tabs.

$ property

A convenient shortcut for looking up an element by ID in the component's Shadow DOM subtree.

Example: if component's template contains a shadow element <button id="foo">, you can use the reference this.$.foo to obtain the corresponding button in the component instance's shadow tree. The $ function is simply a shorthand for getElementById, so this.$.foo is the same as this.shadowRoot.getElementById('foo').

Type: object

Defined by ShadowTemplateMixin

canSelectNext property

True if the selection can be moved to the next item, false if not (the selected item is the last item in the list).

Type: boolean

Defined by SingleSelectionMixin

canSelectPrevious property

True if the selection can be moved to the previous item, false if not (the selected item is the first one in the list).

Type: boolean

Defined by SingleSelectionMixin

defaultState property

The default state for the component. This can be extended by mixins and classes to provide additional default state.

Type: State

Defined by ReactiveMixin

items property

The current set of items drawn from the element's current state.

Type: Array.|null

Defined by ContentItemsMixin

items-changed event

Raised when the items property changes.

Defined by ContentItemsMixin

position property

The position of the tab strip with respect to the associated tab panels.

Setting this property does not actually change the tab strip's position in the document, but works as a signal to the contained tab buttons as to how they should present themselves. The standard TabButton uses this information, for example, to remove the visible border between the tab button and its associated panel.

Type: 'bottom'|'left'|'right'|'top'

Default: 'top'

render() method

Render pending component changes to the DOM.

This method does nothing if the state has not changed since the last render call.

This method invokes all internal render methods. It then invoked componentDidMount (for first render) or componentDidUpdate (for subsequent renders).

Defined by ReactiveMixin

selected-index-changed event

Raised when the selectedIndex property changes.

Defined by SingleSelectionMixin

selectedIndex property

The index of the currently-selected item, or -1 if no item is selected.

Type: number

Defined by SingleSelectionMixin

selectedItem property

The currently-selected item, or null if no item is selected.

Type: Element

Defined by SingleSelectionMixin

selectFirst() method

Select the first item in the list.

Returns: Boolean True if the selection changed, false if not.

Defined by SingleSelectionMixin

selectionRequired property

True if the list should always have a selection (if it has items).

Type: boolean

Default: false

Defined by SingleSelectionMixin

selectionWraps property

True if selection navigations wrap from last to first, and vice versa.

Type: boolean

Default: false

Defined by SingleSelectionMixin

selectLast() method

Select the last item in the list.

Returns: Boolean True if the selection changed, false if not.

Defined by SingleSelectionMixin

selectNext() method

Select the next item in the list.

If the list has no selection, the first item will be selected.

Returns: Boolean True if the selection changed, false if not.

Defined by SingleSelectionMixin

selectPrevious() method

Select the previous item in the list.

If the list has no selection, the last item will be selected.

Returns: Boolean True if the selection changed, false if not.

Defined by SingleSelectionMixin

setState(changes) method

Update the component's state by merging the specified changes on top of the existing state. If the component is connected to the document, and the new state has changed, this returns a promise to asynchronously render the component. Otherwise, this returns a resolved promise.

Parameters:

  • changes: objectthe changes to apply to the element's state

Returns: Promise - resolves when the new state has been rendered

Defined by ReactiveMixin

state property

The component's current state. The returned state object is immutable. To update it, invoke setState.

Type: State

Defined by ReactiveMixin

[symbols.contentSlot] property

Defined by SlotContentMixin

[symbols.goDown]() method

Invokes selectNext to select the next item.

Defined by DirectionSelectionMixin

[symbols.goEnd]() method

Invokes selectLast to select the next item.

Defined by DirectionSelectionMixin

[symbols.goLeft]() method

Invokes selectPrevious to select the previous item.

If the element has a rightToLeft property and it is true, then this selects the next item.

Defined by DirectionSelectionMixin

[symbols.goRight]() method

Invokes selectNext to select the next item.

If the element has a rightToLeft property and it is true, then this selects the previous item.

Defined by DirectionSelectionMixin

[symbols.goStart]() method

Invokes selectFirst to select the first item.

Defined by DirectionSelectionMixin

[symbols.goUp]() method

Invokes selectPrevious to select the previous item.

Defined by DirectionSelectionMixin

[symbols.itemMatchesState](item, state) method

Returns true if the given item should be shown in the indicated state.

Parameters:

  • item: HTMLElement|SVGElement
  • state: PlainObject

Returns: boolean

Defined by ContentItemsMixin

[symbols.keydown]() method

See the symbols documentation for details.

Defined by KeyboardMixin

[symbols.render](changed) method

Internal method for rendering any recent changes in state to the DOM.

The default implementation of this method does nothing. Override this method in your component to update your component's host element and any shadow elements to reflect the component's new state. See the rendering example.

Be sure to call super in your method implementation so that your component's base classes and mixins have a chance to perform their own render work.

Parameters:

  • changed: objectdictionary of flags indicating which state members have changed since the last render

Defined by ReactiveMixin

tabAlign property

The alignment of the tabs within the tab strip.

Type: 'start'|'center'|'end'|'stretch'

Default: 'start'