Skip to main content

TabBar

info

Example file: 07_Work_with_Widgets/tabbar_buttontabbar_objet.lfp

The TabBar widget lays out several tabs horizontally so a tap switches the screen or content.

Definition and role

The TabBar widget arranges labeled tabs in a horizontal row and draws an indicator line under the selected tab. Tapping a tab runs the onChanged action and passes the selected index. You can also set the indicator, label colors and styles, and whether the bar scrolls.

  • Category: Contents (navigation)
  • When first placed, it holds three empty tabs. Customize them to fit your app.

Features

FeatureDescription
Tab switchingTapping a tab changes the selection and runs onChanged.
Tab editing (script)Add or replace tabs and read their labels from a script.
Indicator settingsAdjust the color, thickness, and width basis (tab or label) of the selection indicator.
Label stylesSet colors and styles for selected and unselected labels, and whether the bar scrolls horizontally.

How to use

  1. Open the Contents category in the left widget palette.
  2. Drag the TabBar item onto the canvas.
  3. Edit the labels in the tab list (tabs) to the values you want.
  4. If you need one, connect an action to onChanged to run when the tab changes.
  5. Adjust the indicator, label colors, scrolling (isScrollable), and more as needed.

Properties

PropertyDescriptionDefaultValue / Type
indexCurrently selected tab0Integer
tabsTab list (each tab is a label)Three empty tabsList
isScrollableAllow horizontal scrolling when there are many tabsOff (false)true / false
paddingPadding around the whole tab barNot setPadding
indicatorColorColor of the indicator (selection line)Not setColor
indicatorWeightIndicator thickness2Number
indicatorPaddingPadding around the indicator0Padding
indicatorIndicator decorationNot setDecoration
indicatorSizeWhat the indicator width is based ontabtab, label
automaticIndicatorColorAdjustmentAdjust the indicator color automaticallyOn (true)true / false
dividerColorColor of the divider lineNot setColor
labelColorColor of the selected labelNot setColor
labelStyleStyle of the selected labelNot setText style
labelPaddingPadding around labelsNot setPadding
unselectedLabelColorColor of unselected labelsNot setColor
unselectedLabelStyleStyle of unselected labelsNot setText style
dragStartBehaviorBehavior when a drag startsstartstart, down
overlayColorColor of the touch overlayNot setColor
mouseCursorMouse cursorNot setCursor
enableFeedbackUse touch feedbackNot settrue / false
physicsScrolling behaviorNot setScroll physics

Notes and tips

tip

Set indicatorSize to label and the indicator matches the label width; set it to tab and it spans the full tab.

tip

When you have more tabs than fit on screen, turn on isScrollable so the bar scrolls horizontally.

Learn more

tip

For the full set of Widget Controls (Property, Method, and Event) that drive this widget from a script, visit TabBar Widget Control.