> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/library/ui-components/tabs.md).

# 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.

{% hint style="info" %}
Showroom: [Tabs (combined with a Visibility Group) example](https://showroom.appfarm.app/ui-components/tabs), with its setup in Appfarm Create ([register](https://showroom.appfarm.app/sign-up) for access).
{% endhint %}

## 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**](https://docs.appfarm.io/library/ui-components/visibility-group.md).

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**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appfarm.io/library/ui-components/tabs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
