# TabStyle.Builder

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/model/TabStyle.java+class:androidx.car.app.model.TabStyle.Builder) Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

*** ** * ** ***


```
@RequiresCarApi(value = 9)
@ExperimentalCarApi
class TabStyle.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder#Builder()()` Returns an empty `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder` instance. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder#Builder(androidx.car.app.model.TabStyle)(tabStyle: https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle)` Creates a new `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder`, populated from the input `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder#build()()` Constructs a `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle` from the current state of this builder. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder#setSelectedBackgroundColor(androidx.car.app.model.CarColor)(selectedBackgroundColor: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor?)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor` of the tab indicator background when selected, or `null` to clear the color. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder#setShape(androidx.car.app.model.Shape)(shape: https://developer.android.com/reference/kotlin/androidx/car/app/model/Shape?)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Shape` of the container, or `null` to clear the shape. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder#setTextColor(androidx.car.app.model.CarColor)(textColor: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor?)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor` for text displayed within the tab container, or `null` to clear the color. |

## Public constructors

### Builder

Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

```
Builder()
```

Returns an empty `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder` instance.

### Builder

Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

```
Builder(tabStyle: TabStyle)
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle.Builder`, populated from the input `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle`.

## Public functions

### build

Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

```
fun build(): TabStyle
```

Constructs a `https://developer.android.com/reference/kotlin/androidx/car/app/model/TabStyle` from the current state of this builder.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if shape, selected background color, and text color are all unset. |

### setSelectedBackgroundColor

Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

```
fun setSelectedBackgroundColor(selectedBackgroundColor: CarColor?): TabStyle.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor` of the tab indicator background when selected, or `null` to clear the color.

If a selected background color is not set or is cleared, the background color will fall back to host defaults.

Custom background colors are applied only when the tab is active (selected). On an unselected tab, the background color is ignored by the host and defaults to transparent.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `selectedBackgroundColor` contains an unsupported color type |

### setShape

Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

```
fun setShape(shape: Shape?): TabStyle.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Shape` of the container, or `null` to clear the shape.

If a shape is not set or is cleared, the container shape will fall back to host defaults.

### setTextColor

Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

```
fun setTextColor(textColor: CarColor?): TabStyle.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor` for text displayed within the tab container, or `null` to clear the color.

If a text color is not set or is cleared, the text color will fall back to host defaults.

To customize the color of the tab's icon, see `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIconStyle.Builder#setTint(androidx.car.app.model.CarColor)`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `textColor` contains an unsupported color type |