Rokkit 1.0.3

Tabs

Navigate between different content sections with flexible layouts and interactive controls

The Tabs component is a highly extensible and versatile UI element that simplifies navigation within your application. Like other Rokkit components, Tabs follows the data-first design principle, allowing you to work with any data structure while maintaining full control over styling and behavior.

With support for horizontal and vertical orientations, editable tabs, and custom content rendering, the Tabs component adapts to your specific needs while providing excellent accessibility and keyboard navigation support.

Getting Started

Get started with basic tabs using a simple string array. Notice how the description is stored as an attribute in the data, eliminating the need for conditional logic:

No preview available
Example

Object Data with Custom Snippets

Use complex objects with custom snippets to create rich, interactive tab interfaces. The `child` snippet customizes tab headers while the content between the tags renders as the tab content:

No preview available
Example

Interactive Configuration

Explore the three key layout properties: orientation, position, and align. Try different combinations to see how they affect the tab layout:

No preview available
Example

Editable Tabs

Enable dynamic tab management with the editable property and event handlers. This example starts with empty tabs and demonstrates add/remove functionality:

No preview available
Example

Properties

Complete reference of all available properties:

PropertyTypeDefaultDescription
itemsany[][]Array of tab items (strings or objects)
valueanynullSelected tab value (bindable)
fieldsFieldMappingField mappings for data extraction
orientation'horizontal' | 'vertical''horizontal'Layout direction of the tab bar
position'before' | 'after''before'Position of tab bar relative to content
align'start' | 'center' | 'end''start'Alignment of tabs within the tab bar
editablebooleanfalseEnable add/remove tab functionality
placeholderstring'Select a tab...'Text shown when no tab is selected
tabindexnumber0Tab index for keyboard navigation
namestring'tabs'Name for accessibility (aria-label)
classstring''Additional CSS class names

Events

Available event handlers for user interactions:

EventParametersDescription
onselect(data: {value, selected})Fired when a tab is selected
onchange(data: {value, selected})Fired when the selected tab changes
onmove(data: {value, selected})Fired when focus moves between tabs
onadd()Fired when add button is clicked (editable mode)
onremove(item: any)Fired when a tab is removed (editable mode)

Styling with Data Attributes

The Tabs component uses data attributes for styling hooks, allowing you to customize the appearance without modifying the component itself:

Container Attributes

  • data-tab-root - Root container
  • data-tab-orientation - Orientation value
  • data-tab-position - Position value
  • data-tab-align - Alignment value

Element Attributes

  • data-tab-list - Tab bar container
  • data-tab-item - Individual tab button
  • data-tab-content - Content container
  • data-tab-add - Add button (editable)
  • data-tab-remove - Remove button (editable)

Example Styling

Highlighting code...