# CompactChip.Builder

# CompactChip.Builder

Artifact:[androidx.wear.protolayout:protolayout-material](https://developer.android.com/jetpack/androidx/releases/wear-protolayout)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/material/CompactChip.java+class:androidx.wear.protolayout.material.CompactChip.Builder)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder "View this page in Java")

<br />

```
class CompactChip.Builder
```

<br />

*** ** * ** ***

Builder class for[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip).

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#Builder(android.content.Context,androidx.wear.protolayout.ModifiersBuilders.Clickable,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` clickable: `[ModifiersBuilders.Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)`,` ` deviceParameters: `[DeviceParametersBuilders.DeviceParameters](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters) `)` Creates a builder for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip)with associated action.                                                                                                                                   |
| [Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#Builder(android.content.Context,java.lang.String,androidx.wear.protolayout.ModifiersBuilders.Clickable,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` text: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` clickable: `[ModifiersBuilders.Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)`,` ` deviceParameters: `[DeviceParametersBuilders.DeviceParameters](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters) `)` Creates a builder for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip)with associated action and the given text. |

|                                                     ### Public functions                                                     |
|------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip)                 | [build](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#build())`()` Constructs and returns[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip)with the provided content and look.                                                                                                                                                                                                               |
| [CompactChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder) | [setChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#setChipColors(androidx.wear.protolayout.material.ChipColors))`(chipColors: `[ChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors)`)` Sets the colors for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip).                                                           |
| [CompactChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder) | [setContentDescription](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#setContentDescription(java.lang.CharSequence))`(contentDescription: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`)` Sets the static content description for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip).                                                  |
| [CompactChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder) | [setContentDescription](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#setContentDescription(androidx.wear.protolayout.TypeBuilders.StringProp))`(contentDescription: `[TypeBuilders.StringProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TypeBuilders.StringProp)`)` Sets the content description for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip). |
| [CompactChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder) | [setIconContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#setIconContent(java.lang.String))`(imageResourceId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Sets the icon for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip).                                                                                                            |
| [CompactChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder) | [setTextContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#setTextContent(java.lang.String))`(text: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Sets the text for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip).                                                                                                                       |

## Public constructors

### Builder

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.2.0)  

```
Builder(
    context: Context,
    clickable: ModifiersBuilders.Clickable,
    deviceParameters: DeviceParametersBuilders.DeviceParameters
)
```

Creates a builder for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip)with associated action. Please add text, icon or both content with[setTextContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#setTextContent(java.lang.String))and[setIconContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip.Builder#setIconContent(java.lang.String)).  

|                                                                                     Parameters                                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                                          | The application's context.                                                                                                                                                                                       |
| `clickable: `[ModifiersBuilders.Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)                                    | Associated[Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)for click events. When the CompactChip is clicked it will fire the associated action. |
| `deviceParameters: `[DeviceParametersBuilders.DeviceParameters](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters) | The device parameters used for styling text.                                                                                                                                                                     |

### Builder

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
Builder(
    context: Context,
    text: String,
    clickable: ModifiersBuilders.Clickable,
    deviceParameters: DeviceParametersBuilders.DeviceParameters
)
```

Creates a builder for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip)with associated action and the given text.  

|                                                                                     Parameters                                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                                          | The application's context.                                                                                                                                                                                       |
| `text: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                                           | The text to be displayed in this compact chip.                                                                                                                                                                   |
| `clickable: `[ModifiersBuilders.Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)                                    | Associated[Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)for click events. When the CompactChip is clicked it will fire the associated action. |
| `deviceParameters: `[DeviceParametersBuilders.DeviceParameters](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters) | The device parameters used for styling text.                                                                                                                                                                     |

## Public functions

### build

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
fun build(): CompactChip
```

Constructs and returns[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip)with the provided content and look.  

### setChipColors

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
fun setChipColors(chipColors: ChipColors): CompactChip.Builder
```

Sets the colors for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip). If set,[getBackgroundColor](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors#getBackgroundColor())will be used for the background of the button and[getContentColor](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors#getContentColor())for the text. If not set,[COMPACT_PRIMARY_COLORS](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipDefaults#COMPACT_PRIMARY_COLORS())will be used.  

### setContentDescription

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.2.0)  

```
fun setContentDescription(contentDescription: CharSequence): CompactChip.Builder
```

Sets the static content description for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip). It is highly recommended to provide this for chip containing an icon.  

### setContentDescription

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.2.0)  

```
fun setContentDescription(contentDescription: TypeBuilders.StringProp): CompactChip.Builder
```

Sets the content description for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip). It is highly recommended to provide this for chip containing an icon.

While this field is statically accessible from 1.0, it's only bindable since version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).  

### setIconContent

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
fun setIconContent(imageResourceId: String): CompactChip.Builder
```

Sets the icon for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip). Provided icon will be tinted to the given content color from[ChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors). This icon should be image with chosen alpha channel that can be tinted.  

### setTextContent

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.2.0)  

```
fun setTextContent(text: String): CompactChip.Builder
```

Sets the text for the[CompactChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip).