# CompactChip

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

*** ** * ** ***


```
class CompactChip : LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> Use the new class `https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CompactChip` which provides the same API and functionality.

Tiles component `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip` that represents clickable object with the text.

The Chip is Stadium shape and has a max height designed to take no more than one line of text of `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Typography#TYPOGRAPHY_CAPTION1()` style. Width of the chip is adjustable to the text size.

The recommended set of `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/ChipColors` styles can be obtained from `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/ChipDefaults`., e.g. `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/ChipDefaults#COMPACT_PRIMARY_COLORS()` to get a color scheme for a primary `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip`.

When accessing the contents of a container for testing, note that this element can't be simply casted back to the original type, i.e.:

```kotlin
CompactChip chip = new CompactChip...
Box box = new Box.Builder().addContent(chip).build();

CompactChip myChip = (CompactChip) box.getContents().get(0);
```
will fail.

To be able to get `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip` object from any layout element, `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement)` method should be used, i.e.:

```kotlin
CompactChip myChip = CompactChip.fromLayoutElement(box.getContents().get(0));
```

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip.Builder : https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.LayoutElement.Builder` **This class is deprecated.** Deprecated in Java |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip?` | `[fromLayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(element: https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.LayoutElement)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/ChipColors` | `[getChipColors](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip#getChipColors())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/ModifiersBuilders.Clickable` | `[getClickable](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip#getClickable())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `[getText](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip#getText())()` **This function is deprecated.** Deprecated in Java |

## Public functions

### fromLayoutElement

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

```
java-static fun [fromLayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(element: LayoutElementBuilders.LayoutElement): CompactChip?
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Returns CompactChip object from the given androidx.wear.tiles.LayoutElementBuilders.LayoutElement (e.g. one retrieved from a container's content with `container.getContents().get(index)`) if that element can be converted to CompactChip. Otherwise, it will return null.

### getChipColors

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

```
fun [getChipColors](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip#getChipColors())(): ChipColors
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Returns chip color of this Chip.

### getClickable

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

```
fun [getClickable](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip#getClickable())(): ModifiersBuilders.Clickable
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Returns click event action associated with this Chip.

### getText

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

```
fun [getText](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/CompactChip#getText())(): String
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Returns text content of this Chip.