Skip to content

Material ​

A translucent frosted-glass surface that sits over content and lets it show through — layered, never opaque. Use it for floating chrome such as nav bars, popovers, and bottom sheets.

Import ​

kotlin
import io.github.heartcoolman.prism.glass.PrismMaterial
import io.github.heartcoolman.prism.glass.MaterialThickness

Basic usage ​

kotlin
PrismMaterial(thickness = MaterialThickness.Regular) {
    Text("Material", modifier = Modifier.padding(PrismTheme.spacing.s4))
}

Thickness ​

The material's translucency thickens with elevation (nav < popover < sheet).

kotlin
PrismMaterial(thickness = MaterialThickness.UltraThin) {
    Text("Nav bar", modifier = Modifier.padding(PrismTheme.spacing.s4))
}

PrismMaterial(thickness = MaterialThickness.Thick) {
    Text("Bottom sheet", modifier = Modifier.padding(PrismTheme.spacing.s4))
}

Shape and progressive edge ​

Pass a shape to clip the surface, and set progressive = true to ramp the material to clear along its bottom edge (for bars that dissolve content rather than ending on a hard line).

kotlin
PrismMaterial(
    shape = RoundedCornerShape(PrismTheme.radius.card),
    progressive = true,
) {
    Text("Dissolving bar", modifier = Modifier.padding(PrismTheme.spacing.s4))
}

Modifier form ​

The same surface is available as a Modifier extension when you do not need a wrapping Box:

kotlin
Box(Modifier.prismMaterial(thickness = MaterialThickness.Thin)) {
    Text("Chrome")
}

API ​

PrismMaterial ​

ParameterTypeDefaultDescription
modifierModifierModifierModifier applied to the surface Box.
thicknessMaterialThicknessMaterialThickness.RegularBlur/translucency tier; thickens with elevation.
shapeShapeRectangleShapeShape used to clip and border the surface.
progressiveBooleanfalseRamps the material to clear along the bottom edge.
content@Composable BoxScope.() -> Unit—Content rendered over the material.

MaterialThickness ​

ValueDescription
UltraThinLightest translucency (alpha scale 0.70).
ThinLight translucency (alpha scale 0.85).
RegularDefault translucency (alpha scale 1.00).
ThickHeaviest translucency (alpha scale 1.15).

Assumes an enclosing PrismTheme { }; colors are read from PrismTheme.colors.materialBg and PrismTheme.colors.separator.

Released under the MIT License.