# 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
public final class TabStyle.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder#Builder()()` Returns an empty `https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder` instance. |
| `https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder#Builder(androidx.car.app.model.TabStyle)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/TabStyle tabStyle)` Creates a new `https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder`, populated from the input `https://developer.android.com/reference/androidx/car/app/model/TabStyle`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/TabStyle` | `https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder#build()()` Constructs a `https://developer.android.com/reference/androidx/car/app/model/TabStyle` from the current state of this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder` | `https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder#setSelectedBackgroundColor(androidx.car.app.model.CarColor)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarColor selectedBackgroundColor)` Sets the `https://developer.android.com/reference/androidx/car/app/model/CarColor` of the tab indicator background when selected, or `null` to clear the color. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder` | `https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder#setShape(androidx.car.app.model.Shape)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/Shape shape)` Sets the `https://developer.android.com/reference/androidx/car/app/model/Shape` of the container, or `null` to clear the shape. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder` | `https://developer.android.com/reference/androidx/car/app/model/TabStyle.Builder#setTextColor(androidx.car.app.model.CarColor)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarColor textColor)` Sets the `https://developer.android.com/reference/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)

```
public Builder()
```

Returns an empty `https://developer.android.com/reference/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)

```
public Builder(@NonNull TabStyle tabStyle)
```

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

## Public methods

### build

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

```
public @NonNull TabStyle build()
```

Constructs a `https://developer.android.com/reference/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)

```
public @NonNull TabStyle.Builder setSelectedBackgroundColor(@Nullable CarColor selectedBackgroundColor)
```

Sets the `https://developer.android.com/reference/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)

```
public @NonNull TabStyle.Builder setShape(@Nullable Shape shape)
```

Sets the `https://developer.android.com/reference/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)

```
public @NonNull TabStyle.Builder setTextColor(@Nullable CarColor textColor)
```

Sets the `https://developer.android.com/reference/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/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 |