Tabs

Tabs is a set of tabbed panels that can be navigated by selecting corresponding tab buttons (which must be supplied by the developer). A typical example of Tabs being used for navigation:

<elix-tabs>

  <button slot="tabButtons">Home</button>
  <div>Home page</div>

  <button slot="tabButtons">Search</button>
  <div>Search page</div>

  <button slot="tabButtons">Settings</button>
  <div>Settings page</div>

</elix-tabs>

When styling and icons are added, the result might be:

home
Home
search
Search
settings
Settings
Home page
Search page
Settings page
Demo: Tabs used for navigation

Tabs is a general-purpose component that takes care of the relative positioning of the tab buttons and the tab panels, and ensures that the selection state of the buttons and panels remains in sync. As shown above, when using Tabs directly you will need to supply your own tab buttons.

A subclass of Tabs called LabeledTabs automatically generates generic tab buttons for each tab panel:

Page one
Page two
Page three

Show tabs on:     Align tabs:

Demo: LabeledTabs, showing options for tab button position and alignment

The Tabs class is registered as element <elix-tabs>.

Usage

Use Tabs for situations in which the user can directly control which modal state is presented. Tabs are typically used to allow a UI to offer more controls than can fit in a confined area at a time.

  • A common use case is Settings or configuration UIs. Here the classic look of a tabbed dialog or property sheet is addressed with LabeledTabs, although other looks are possible.
  • Tabs may also be used in a main window to downplay less-commonly used aspects of a UI.
  • Tabs are also an extremely common navigation model. Many mobile applications present a navigation toolbar that behave like tabs, presenting 3–5 buttons that correspond to the app's main areas. In navigation use cases, the tab buttons typically have a toolbar button style rather than a classic tabbed appearance.

In practice, what is fundamentally behaving like tabs may have widely varying tab buttons or visual transition effects. To accommodate those use cases, Tabs is constructed from lower-lever parts you can recombine to create more specialized tab UIs.

For example, the Tabs component assumes a standard tabbed UI design in which clicking a tab immediately makes the corresponding tab panel visible. To manage that visual transition, Tabs internally on TabStripWrapper to apply a TabStrip to an instance of Modes. If, however, you wish to provide other visual effects for the transition between panels (e.g., a sliding animation), you can create your own variant of Tabs by applying TabStripWrapper to a component of your own that contains the tab panels. See TabStripWrapper for details.

API

attributeChangedCallback() method

Handle a change to the attribute with the given name.

Defined by AttributeMarshallingMixin inherited from Modes

attributesForClass() method

Return the custom attributes for the given class.

Inherited from module:AttributeMarshallingMixin

attributeToPropertyName() method

Convert hyphenated foo-bar attribute name to camel case fooBar property name.

Inherited from module:AttributeMarshallingMixin

can-select-next-changed event

Fires when the canSelectNext property changes in response to internal component activity.

Defined by SingleSelectionMixin inherited from Modes

can-select-previous-changed event

Fires when the canSelectPrevious property changes in response to internal component activity.

Defined by SingleSelectionMixin inherited from Modes

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 inherited from Modes

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 inherited from Modes

items property

The current set of items in the list. See the top-level documentation for mixin for a description of how items differ from plain content.

Type: Array.<Element>

Defined by ContentItemsMixin inherited from Modes

items-changed event

Fires when the items in the list change.

Defined by ContentItemsMixin inherited from Modes

propertyNameToAttribute() method

Convert a camel case fooBar property name to a hyphenated foo-bar attribute.

Inherited from module:AttributeMarshallingMixin

reflectAttribute(attribute, value) method

Set/unset the attribute with the indicated name.

This method exists primarily to handle the case where an element wants to set a default property value that should be reflected as an attribute. An important limitation of custom element consturctors is that they cannot set attributes. A call to reflectAttribute during the constructor will be deferred until the element is connected to the document.

Parameters:
  • attribute: stringThe name of the *attribute* (not property) to set.
  • value: objectThe value to set. If null, the attribute will be removed.

Defined by AttributeMarshallingMixin inherited from Modes

reflectClass(className, value) method

Set/unset the class with the indicated name.

This method exists primarily to handle the case where an element wants to set a default property value that should be reflected as as class. An important limitation of custom element consturctors is that they cannot set attributes, including the class attribute. A call to reflectClass during the constructor will be deferred until the element is connected to the document.

Parameters:
  • className: stringThe name of the class to set.
  • value: booleanTrue to set the class, false to remove it.

Defined by AttributeMarshallingMixin inherited from Modes

selected-index-changed event

Fires when the selectedIndex property changes in response to internal component activity.

Defined by SingleSelectionMixin inherited from Modes

selected-item-changed event

Fires when the selectedItem property changes in response to internal component activity.

Defined by SingleSelectionMixin inherited from Modes

selectedIndex property

The index of the item which is currently selected.

The setter expects an integer or a string representing an integer.

A selectedIndex of -1 indicates there is no selection. Setting this property to -1 will remove any existing selection.

Type: number

Defined by SingleSelectionMixin inherited from Modes

selectedItem property

The currently selected item, or null if there is no selection.

Setting this property to null deselects any currently-selected item. Setting this property to an object that is not in the list has no effect.

Type: Element

Defined by SingleSelectionMixin inherited from Modes

selectFirst() method

Select the first item in the list.

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

Defined by SingleSelectionMixin inherited from Modes

selectIndex() method

Ensure the given index is within bounds, and select it if it's not already selected.

Inherited from module:SingleSelectionMixin

selectionRequired property

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

Type: boolean

Default: false

Defined by SingleSelectionMixin inherited from Modes

selectionWraps property

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

Type: boolean

Default: false

Defined by SingleSelectionMixin inherited from Modes

selectLast() method

Select the last item in the list.

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

Defined by SingleSelectionMixin inherited from Modes

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 inherited from Modes

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 inherited from Modes

symbols.content property

The content of this component, defined to be the flattened set of nodes assigned to its default unnamed slot.

Type: Array.<Element>

Defined by DefaultSlotContentMixin inherited from Modes

symbols.itemAdded(item) method

Handle a new item being added to the list.

The default implementation of this method simply sets the item's selection state to false.

Parameters:
  • item: Elementthe item being added

Defined by SingleSelectionMixin inherited from Modes

symbols.itemsChanged() method

This method is invoked when the underlying contents change. It is also invoked on component initialization – since the items have "changed" from being nothing.

Defined by ContentItemsMixin inherited from Modes

symbols.itemSelected(item, selected) method

Apply the indicate selection state to the item.

The default implementation of this method does nothing. User-visible effects will typically be handled by other mixins.

Parameters:
  • item: Elementthe item being selected/deselected
  • selected: booleantrue if the item is selected, false if not

Defined by SingleSelectionMixin inherited from Modes

trackSelectedItem() method

Following a change in the set of items, or in the value of the selectionRequired property, reacquire the selected item. If it's moved, update selectedIndex. If it's been removed, and a selection is required, try to select another item.

Inherited from module:SingleSelectionMixin

updatePossibleNavigations() method

Following a change in selection, report whether it's now possible to go next/previous from the given index.

Inherited from module:SingleSelectionMixin

© 2016-2017 Component Kitchen Inc. and contributors to the Elix project. ELIX and the Elix project logo are registered or unregistered trademarks of Component Kitchen Inc. in the United States and/or other countries. Other trademarks are the property of their respective owners. Any use of such trademarks without written permission sought and obtained from Component Kitchen is prohibited.

The Elix project is administered, as a courtesy, by Component Kitchen for the benefit of the project’s contributors and the developer community as a whole.