PreviewWrapperProvider


Interface used to define custom rendering logic for Compose Previews in Android Studio.

Implementations of this interface allow developers to wrap the content of a Preview to provide specific environments, themes, or containers (such as a Remote Compose) without requiring repetitive code in every preview function.

Usage: Implementations are applied to previews using the PreviewWrapper annotation.

See also
PreviewWrapper

Summary

Public functions

Unit
@Composable
Wrap(content: @Composable () -> Unit)

Wraps the provided content with custom UI logic or containers.

Cmn

Public functions

Wrap

@Composable
fun Wrap(content: @Composable () -> Unit): Unit

Wraps the provided content with custom UI logic or containers.

Example usage for applying a Theme:

class CustomThemeWrapper : PreviewWrapperProvider {
@Composable
override fun Wrap(content: @Composable () -> Unit) {
// Apply a light theme and provide a full-screen Surface to set a default background
// color for the preview content.
MaterialTheme(colorScheme = lightColorScheme()) {
Surface(modifier = Modifier.fillMaxSize()) {
content()
}
}
}
}
Parameters
content: @Composable () -> Unit

The original composable content of the function annotated with Preview.