Android 12 Developer Preview is here! Try it out, and give us your feedback!

SnackbarDefaults

object SnackbarDefaults
kotlin.Any
   ↳ androidx.compose.material.SnackbarDefaults

Object to hold defaults used by Snackbar

Summary

Properties
Color

Default background color of the Snackbar

Color

Provides a best-effort 'primary' color to be used as the primary color inside a Snackbar.

Properties

backgroundColor

val backgroundColor: Color

Default background color of the Snackbar

primaryActionColor

val primaryActionColor: Color

Provides a best-effort 'primary' color to be used as the primary color inside a Snackbar. Given that Snackbars have an 'inverted' theme, i.e in a light theme they appear dark, and in a dark theme they appear light, just using Colors.primary will not work, and has incorrect contrast.

If your light theme has a corresponding dark theme, you should instead directly use Colors.primary from the dark theme when in a light theme, and use Colors.primaryVariant from the dark theme when in a dark theme.

When in a light theme, this function applies a color overlay to Colors.primary from MaterialTheme.colors to attempt to reduce the contrast, and when in a dark theme this function uses Colors.primaryVariant.