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

*** ** * ** ***


```
public class CompactChip implements LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

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

Tiles component `https://developer.android.com/reference/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/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/androidx/wear/tiles/material/ChipColors` styles can be obtained from `https://developer.android.com/reference/androidx/wear/tiles/material/ChipDefaults`., e.g. `https://developer.android.com/reference/androidx/wear/tiles/material/ChipDefaults#COMPACT_PRIMARY_COLORS()` to get a color scheme for a primary `https://developer.android.com/reference/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.:

```
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/androidx/wear/tiles/material/CompactChip` object from any layout element, `https://developer.android.com/reference/androidx/wear/tiles/material/CompactChip#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement)` method should be used, i.e.:

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

## Summary

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

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/tiles/material/CompactChip` | `[fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/CompactChip#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.LayoutElement element)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/material/ChipColors` | `[getChipColors](https://developer.android.com/reference/androidx/wear/tiles/material/CompactChip#getChipColors())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/ModifiersBuilders.Clickable` | `[getClickable](https://developer.android.com/reference/androidx/wear/tiles/material/CompactChip#getClickable())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `[getText](https://developer.android.com/reference/androidx/wear/tiles/material/CompactChip#getText())()` **This method is deprecated.** Deprecated in Java |

## Public methods

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

```
public static @Nullable CompactChip [fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/CompactChip#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(@NonNull LayoutElementBuilders.LayoutElement element)
```

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

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

Returns text content of this Chip.