haze
2.0.0-alpha03indexedBackground blurring for Compose Multiplatform / Jetpack Compose
Background blurring for Compose Multiplatform / Jetpack Compose
Composable visual effects for Compose Multiplatform.
https://github.com/user-attachments/assets/836dd79a-abdc-4cdc-b27d-baee394c1e26
Haze provides hardware-accelerated visual effects for Compose Multiplatform — Android, iOS, macOS, Desktop, and Web. Its modular Haze 2 API lets you apply source-backed or own-content Blur, refraction-driven Glass, and custom effects with explicit, reusable configuration.
Haze 2.0 is currently in beta. If you are upgrading from Haze 1.x or an earlier Haze 2 prerelease, see the Haze 2 migration guide.
| Platform | Support |
|---|---|
| Android | ✅ |
Add the core module and only the effect modules you use. Keep every Haze artifact on the same version.
dependencies {
// Core infrastructure and Blur
implementation("dev.chrisbanes.haze:haze:<version>")
implementation("dev.chrisbanes.haze:haze-blur:<version>")
// Optional: ready-made Blur styles
implementation("dev.chrisbanes.haze:haze-blur-materials:<version>")
}
For Glass, add the core module and the experimental Glass artifact:
dependencies {
implementation("dev.chrisbanes.haze:haze:<version>")
implementation("dev.chrisbanes.haze:haze-glass:<version>")
}
val hazeState = rememberHazeState()
Box {
Image(
painter = painter,
contentDescription = null,
modifier = Modifier.hazeSource(hazeState),
)
Box(
modifier = Modifier
.matchParentSize()
.hazeBlur(
input = HazeInput.Sources(hazeState),
style = HazeBlurStyle { blurRadius(20.dp) },
),
)
}
HazeInput.Sources renders captured hazeSource content. Use HazeInput.Content to blur the modifier's own content instead. HazeBlurStyle is immutable and reusable; use then to derive a variation or supply a replacement Style when its appearance changes.
The optional Blur material presets provide HazeMaterials.ultraThin(), thin(), regular(), thick(), and . The provides for a Style based on the current Material 3 surface.
haze-glass is an experimental Haze 2 module for material-like Glass: refraction, depth Blur, tint, lighting, highlights, rounded shapes, and optional pointer, focus, and press responses. Glass APIs require @ExperimentalHazeApi.
Modifier.hazeGlass(
input = HazeInput.Sources(hazeState),
style = GlassStyle.regular.then {
tint(Color.White.copy(alpha = 0.16f))
shape(RoundedCornerShape(20.dp))
},
)
Start with GlassStyle.regular, or use GlassStyle.clear when the background should remain more
visible. Consult the Glass guide for custom
optics, interaction, retention, and platform fallback behavior. Add haze-glass-material3 to use
GlassStyle.Material3() or material3() with your current Material 3 surface color. Regular and
Clear follow the system appearance without Material 3. The optional integration supplies the app
theme's surface color and can add a tint.
Built-in Blur and Glass use HazePerformanceMode.Default, which selects the fixed Balanced profile. Begin with that setting and measure a release-like build on representative devices before selecting Quality, , or . remains as a deprecated compatibility alias for . Custom effects keep the separate policy. See the for the decision framework and effect-specific guidance.
Blur and Glass can process a live camera preview when its pixels are drawn in the same Compose graphics layer as hazeSource. On Android, CameraX requires PreviewView.ImplementationMode.COMPATIBLE; a SurfaceView cannot be captured. The camera guide covers CameraX, Kamera, and the same constraint for video and other platform views.
Copyright 2024 Chris Banes
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance the License.
You may obtain a copy of the License at
https:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
| Desktop (JVM) | ✅ |
| iOS | ✅ |
| macOS | ✅ |
| Wasm / JS | ✅ |
| Artifact | Purpose |
|---|
haze | Source capture and the typed custom-effect API. |
haze-blur | Blur for captured sources or a modifier's own content. |
haze-blur-materials | Optional ready-made Blur Styles, including HazeMaterials.thin(). |
haze-blur-material3 | Optional Compose Material 3 Blur Style factory. |
haze-glass | Experimental, refraction-driven Glass effect. |
haze-glass-material3 | Optional Compose Material 3 Glass Style factory. |
ultraThick()HazeBlurStyle.Material3()PerformanceFixed(...)AdaptiveDefaultHazeSamplingSurfaced from shared tags and platforms — no rankings paid for.