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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-05-15 UTC.
[null,null,["Last updated 2025-05-15 UTC."],[],[],null,["# SnackbarDefaults\n================\n\nArtifact: [androidx.compose.material:material](/jetpack/androidx/releases/compose-material) \n[View Source](https://cs.android.com/search?q=file:androidx/compose/material/Snackbar.kt+class:androidx.compose.material.SnackbarDefaults) \nAdded in [1.0.0](/jetpack/androidx/releases/compose-material#1.0.0)\nCommon/AllAndroid/JVM\n - Cmn \n\n ```\n object SnackbarDefaults\n ```\n\n*** ** * ** ***\n\nObject to hold defaults used by [Snackbar](/reference/kotlin/androidx/compose/material/package-summary#Snackbar(androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,kotlin.Function0))\n\nSummary\n-------\n\n| ### Public properties |\n|---------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|\n| [Color](/reference/kotlin/androidx/compose/ui/graphics/Color) | [backgroundColor](/reference/kotlin/androidx/compose/material/SnackbarDefaults#backgroundColor()) Default background color of the [Snackbar](/reference/kotlin/androidx/compose/material/package-summary#Snackbar(androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,kotlin.Function0)) | Cmn |\n| [Color](/reference/kotlin/androidx/compose/ui/graphics/Color) | [primaryActionColor](/reference/kotlin/androidx/compose/material/SnackbarDefaults#primaryActionColor()) Provides a best-effort 'primary' color to be used as the primary color inside a [Snackbar](/reference/kotlin/androidx/compose/material/package-summary#Snackbar(androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,kotlin.Function0)). | Cmn |\n\nPublic properties\n-----------------\n\n### backgroundColor\n\nCmn \nAdded in [1.0.0](/jetpack/androidx/releases/compose-material#1.0.0) \n\n```\nval backgroundColor: Color\n```\n\nDefault background color of the [Snackbar](/reference/kotlin/androidx/compose/material/package-summary#Snackbar(androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,kotlin.Function0)) \n\n### primaryActionColor\n\nCmn \nAdded in [1.0.0](/jetpack/androidx/releases/compose-material#1.0.0) \n\n```\nval primaryActionColor: Color\n```\n\nProvides a best-effort 'primary' color to be used as the primary color inside a [Snackbar](/reference/kotlin/androidx/compose/material/package-summary#Snackbar(androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,kotlin.Function0)). Given that [Snackbar](/reference/kotlin/androidx/compose/material/package-summary#Snackbar(androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,kotlin.Function0))s 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](/reference/kotlin/androidx/compose/material/Colors#primary()) will not work, and has incorrect contrast.\n\nIf your light theme has a corresponding dark theme, you should instead directly use [Colors.primary](/reference/kotlin/androidx/compose/material/Colors#primary()) from the dark theme when in a light theme, and use [Colors.primaryVariant](/reference/kotlin/androidx/compose/material/Colors#primaryVariant()) from the dark theme when in a dark theme.\n\nWhen in a light theme, this function applies a color overlay to [Colors.primary](/reference/kotlin/androidx/compose/material/Colors#primary()) from [MaterialTheme.colors](/reference/kotlin/androidx/compose/material/MaterialTheme#colors()) to attempt to reduce the contrast, and when in a dark theme this function uses [Colors.primaryVariant](/reference/kotlin/androidx/compose/material/Colors#primaryVariant())."]]