Snackbar
Snackbar presents transient status updates with optional action and dismiss affordances built from the same button primitives as the library.
Anatomy
| Element | Part | Selector |
|---|---|---|
<section> | root | [data-scope="snackbar"][data-part="root"]LMBCopy |
<div> | content | [data-scope="snackbar"][data-part="content"]LMBCopy |
<div> | actionsconditional | [data-scope="snackbar"][data-part="actions"]LMBCopy |
<Button> | action-buttonconditional | [data-scope="snackbar"][data-part="action-button"]LMBCopy |
<IconButton> | dismiss-buttonconditional | [data-scope="snackbar"][data-part="dismiss-button"]LMBCopy |
Props
| Name | Description | Default | Control |
|---|---|---|---|
actionLabelOptional | Label for the optional action button. string | undefined | undefined | |
actionDisabledOptional | Whether the action button is disabled. boolean | undefined | false | |
actionAutofocusOptional | Whether the action button should autofocus when rendered. boolean | undefined | false | |
actionOnNewLineOptional | Whether the action should be placed on a separate line. boolean | undefined | false | |
dismissibleOptional | Whether to show a dismiss button. boolean | undefined | false | |
dismissButtonLabelOptional | Accessible label for the dismiss button. string | undefined | "Dismiss notification" |
Events2
| Name | Type | Description |
|---|---|---|
action | [] | - |
dismiss | [] | - |
Slots3
| Name | Parameters | Description |
|---|---|---|
default | - | Supporting text content for the snackbar. |
action | - | Optional custom action content. |
dismiss | - | Optional custom dismiss content. |
Styling22
| Token | Description |
|---|---|
--md-snackbar-action-label-text-colorColorFallback var(--md-sys-color-inverse-primary) | Controls action label text color. |
--md-snackbar-action-label-text-fontTypographyFallback var(--md-sys-typescale-label-large-font) | Controls action label text font. |
--md-snackbar-action-label-text-line-heightTypographyFallback var(--md-sys-typescale-label-large-line-height) | Controls action label text line height. |
--md-snackbar-action-label-text-sizeLayoutFallback var(--md-sys-typescale-label-large-size) | Controls action label text size. |
--md-snackbar-action-label-text-trackingTypographyFallback var(--md-sys-typescale-label-large-tracking) | Controls action label text tracking. |
--md-snackbar-action-label-text-weightTypographyFallback var(--md-sys-typescale-label-large-weight) | Controls action label text weight. |
--md-snackbar-container-colorColorFallback var(--md-sys-color-inverse-surface) | Controls container color. |
--md-snackbar-container-elevationElevationFallback var(--md-sys-elevation-level3) | Controls container elevation. |
--md-snackbar-container-padding-blockLayoutFallback 1rem | Controls container padding block. |
--md-snackbar-container-padding-inline-endLayoutFallback 0.5rem | Controls container padding inline end. |
--md-snackbar-container-padding-inline-startLayoutFallback 1rem | Controls container padding inline start. |
--md-snackbar-container-shadow-colorColorFallback var(--md-sys-color-shadow) | Controls container shadow color. |
--md-snackbar-container-shapeShapeFallback var(--md-shape-compact) | Controls container shape. |
--md-snackbar-icon-colorColorFallback var(--md-sys-color-inverse-on-surface) | Controls icon color. |
--md-snackbar-icon-sizeLayoutFallback 1.25rem | Controls icon size. |
--md-snackbar-supporting-text-colorColorFallback var(--md-sys-color-inverse-on-surface) | Controls supporting text color. |
--md-snackbar-supporting-text-fontTypographyFallback var(--md-sys-typescale-body-medium-font) | Controls supporting text font. |
--md-snackbar-supporting-text-line-heightTypographyFallback var(--md-sys-typescale-body-medium-line-height) | Controls supporting text line height. |
--md-snackbar-supporting-text-sizeLayoutFallback var(--md-sys-typescale-body-medium-size) | Controls supporting text size. |
--md-snackbar-supporting-text-trackingTypographyFallback var(--md-sys-typescale-body-medium-tracking) | Controls supporting text tracking. |
--md-snackbar-supporting-text-weightTypographyFallback var(--md-sys-typescale-body-medium-weight) | Controls supporting text weight. |
--md-snackbar-with-single-line-container-heightLayoutFallback 3rem | Controls with single line container height. |