For the complete documentation index, see llms.txt. This page is also available as Markdown.

Tabs

Tabs may be added to your UI to represent menus or submenus.

You typically use Tabs inside a view or a dialog, to control which parts of the UI should be displayed. Example: A dialog for displaying info for an Order with two Tabs: Order Info and Order Lines, and you only want to display either Order Info or the Order Lines, depending on which Tab the User clicked.

Showroom: Tabs (combined with a Visibility Group) example, with its setup in Appfarm Create (register for access).

Settings

Active Tab Value

When the user clicks the tabs, the information on which tab is clicked needs to be stored somewhere.

The Tabs UI component itself does not hold the Order Info properties or Order Lines - it only holds

  • Which tab was clicked (stored in the Active Tab Value)

  • Which tabs are available (explained further down)

So, you need a variable to hold this information (which tab was clicked).

  1. Add a variable to your App Variables (the built-in data source under App data in the app's Data tab). It would typically be an integer data type. Example for order dialog: Name the property Order - Active Tab Value and set the default value to 0.

  2. Active Tab Value: Select Data Binding and select the property you added in 1).

Appearance

  • Variant: Standard (default), Full Width or Scrollable.

  • Centered Tabs: Center the tabs.

  • Active Tab Color: The color of the active tab: Primary (default), Secondary or Inherit.

  • Indicator Color: The color of the line under the active tab: Primary (default) or Secondary.

  • Orientation: Horizontal (default) or Vertical.

Tabs

Add a tab, or two, or three.

  • Tab Value: The value written to the property bound in Active Tab Value when this tab is clicked. Defaults to the tab's index (0 for the first tab). You can set it to another value, such as a string, integer, float or enum value, to match the type of the Active Tab Value property.

  • Label: The visible name for the tab.

  • Icon: If you want an icon above the label.

  • Badge: Show a badge on the tab, with a Badge Value and a Badge Color (default Secondary).

  • Visible: Show or hide the tab.

  • Disabled: Make the tab unclickable.

  • On Click: Run an action when the tab is clicked.

Use Tabs to control the visibility of UI Components

In our example above, the value 0 or 1 is saved into App variables.Order - Active Tab Value property when the tabs are clicked.

We simply need to control what should be visible depending on this value.

You could add two Containers, one being visible if Active Tab Value is 0, and another if 1. But let us do something smarter.

The best way to do it is to add a Visibility Group.

A Visibility Group with Control Mode Controlled may have a Visible Index. Select the same property here as in the Active Tab Value, for example, App variables.Order - Active Tab Value.

You may add two Containers inside the Visibility Group, the first is recognized as index 0, the second as index 1.

When the property bound in the Visible Index changes, for example from 0 to 1, the second Container will be displayed - since it is located at index 1 inside the Visibility Group.

Last updated

Was this helpful?