# WearWidgetPreview

## Functions summary

|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/glance/wear/tooling/preview/WearWidgetPreview.composable#WearWidgetPreview(androidx.glance.wear.GlanceWearWidget,androidx.glance.wear.core.WearWidgetParams,androidx.compose.ui.Modifier,kotlin.Boolean)( widget: https://developer.android.com/reference/kotlin/androidx/glance/wear/GlanceWearWidget, params: https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetParams, modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier, useBaselineHostVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Renders a preview of a `https://developer.android.com/reference/kotlin/androidx/glance/wear/GlanceWearWidget` in Android Studio. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/glance/wear/tooling/preview/WearWidgetPreview.composable#WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams,androidx.compose.ui.Modifier,androidx.glance.wear.WearWidgetBrush,kotlin.Boolean,kotlin.Function0)( params: https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetParams, modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier, background: https://developer.android.com/reference/kotlin/androidx/glance/wear/WearWidgetBrush, useBaselineHostVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, content: @https://developer.android.com/reference/kotlin/androidx/compose/remote/creation/compose/layout/RemoteComposable @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Renders a preview of a Wear Widget with the provided Remote Compose `https://developer.android.com/reference/kotlin/androidx/glance/wear/tooling/preview/package-summary#WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams,androidx.compose.ui.Modifier,androidx.glance.wear.WearWidgetBrush,kotlin.Boolean,kotlin.Function0)`. |

## Functions

### WearWidgetPreview

Artifact: [androidx.glance.wear:wear-tooling-preview](https://developer.android.com/jetpack/androidx/releases/glance-wear) [View Source](https://cs.android.com/search?q=file:androidx/glance/wear/tooling/preview/WearWidgetPreview.kt+function:WearWidgetPreview) Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
@Composable
fun WearWidgetPreview(
    widget: GlanceWearWidget,
    params: WearWidgetParams,
    modifier: Modifier = Modifier,
    useBaselineHostVersion: Boolean = false
): Unit
```

Renders a preview of a `https://developer.android.com/reference/kotlin/androidx/glance/wear/GlanceWearWidget` in Android Studio.

This utility facilitates rapid development by allowing developers to visualize how their Glance Wear widgets will appear on various device configurations without deploying to a physical device or emulator. It uses the provided `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetParams` to represent the widget's layout, including dimensions, padding, and container shape.

| Parameters |
|---|---|
| `widget: https://developer.android.com/reference/kotlin/androidx/glance/wear/GlanceWearWidget` | The `https://developer.android.com/reference/kotlin/androidx/glance/wear/GlanceWearWidget` instance to be previewed. |
| `params: https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetParams` | The `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetParams` to configure parameters (size, shape, padding) for the widget container. |
| `modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier = Modifier` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` to be applied to the container box hosting the widget preview. Note that the preview's dimensions are enforced internally based on the provided `https://developer.android.com/reference/kotlin/androidx/glance/wear/tooling/preview/package-summary#WearWidgetPreview(androidx.glance.wear.GlanceWearWidget,androidx.glance.wear.core.WearWidgetParams,androidx.compose.ui.Modifier,kotlin.Boolean)`. Applying layout-modifying modifiers here might conflict with these internal specifications. |
| `useBaselineHostVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | Whether to render using a baseline host version (a foundational, definitively supported version representing older hosts). This allows developers to test widget compatibility against older versions of the Wear OS host. If false, the preview renders using the latest host version. Defaults to false. |

### WearWidgetPreview

Artifact: [androidx.glance.wear:wear-tooling-preview](https://developer.android.com/jetpack/androidx/releases/glance-wear) [View Source](https://cs.android.com/search?q=file:androidx/glance/wear/tooling/preview/WearWidgetPreview.kt+function:WearWidgetPreview) Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/glance-wear#1.0.0-alpha22)

```
@Composable
fun WearWidgetPreview(
    params: WearWidgetParams,
    modifier: Modifier = Modifier,
    background: WearWidgetBrush = WearWidgetBrush.color(Color.Transparent.rc),
    useBaselineHostVersion: Boolean = false,
    content: @RemoteComposable @Composable () -> Unit
): Unit
```

Renders a preview of a Wear Widget with the provided Remote Compose `https://developer.android.com/reference/kotlin/androidx/glance/wear/tooling/preview/package-summary#WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams,androidx.compose.ui.Modifier,androidx.glance.wear.WearWidgetBrush,kotlin.Boolean,kotlin.Function0)`.

This utility facilitates rapid development by allowing developers to visualize how their Glance Wear widgets will appear on various device configurations without deploying to a physical device or emulator. It uses the provided `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetParams` to represent the widget's layout, including dimensions, padding, and container shape.

This overload allows to directly preview a Wear Widget by supplying the Remote Compose `https://developer.android.com/reference/kotlin/androidx/glance/wear/tooling/preview/package-summary#WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams,androidx.compose.ui.Modifier,androidx.glance.wear.WearWidgetBrush,kotlin.Boolean,kotlin.Function0)` and optional `https://developer.android.com/reference/kotlin/androidx/glance/wear/tooling/preview/package-summary#WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams,androidx.compose.ui.Modifier,androidx.glance.wear.WearWidgetBrush,kotlin.Boolean,kotlin.Function0)`. It is convenient for complex widgets that switch between multiple layouts based on application state, avoiding the mocking the entire widget or its dependencies.

| Parameters |
|---|---|
| `params: https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetParams` | The `https://developer.android.com/reference/kotlin/androidx/glance/wear/core/WearWidgetParams` to configure parameters (size, shape, padding) for the widget container. |
| `modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier = Modifier` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` to be applied to the container box hosting the widget preview. |
| `background: https://developer.android.com/reference/kotlin/androidx/glance/wear/WearWidgetBrush = WearWidgetBrush.color(Color.Transparent.rc)` | The `https://developer.android.com/reference/kotlin/androidx/glance/wear/WearWidgetBrush` to be used as the background of the widget. Defaults to a transparent solid color. |
| `useBaselineHostVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | Whether to render using a baseline host version (a foundational, definitively supported version representing older hosts). This allows developers to test widget compatibility against older versions of the Wear OS host. If false, the preview renders using the latest host version. Defaults to false. |
| `content: @https://developer.android.com/reference/kotlin/androidx/compose/remote/creation/compose/layout/RemoteComposable @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` content of the widget to be previewed. |