Snackbar
Snackbar 用于呈现短暂状态更新,可选操作按钮和关闭按钮均由库中相同的按钮基础组件构成。
示例
默认
选项
组合
参考
结构
| 元素 | 部件 | 选择器 |
|---|---|---|
<section> | root | [data-scope="snackbar"][data-part="root"]鼠标左键单击复制 |
<div> | content | [data-scope="snackbar"][data-part="content"]鼠标左键单击复制 |
<div> | actions条件显示 | [data-scope="snackbar"][data-part="actions"]鼠标左键单击复制 |
<Button> | action-button条件显示 | [data-scope="snackbar"][data-part="action-button"]鼠标左键单击复制 |
<IconButton> | dismiss-button条件显示 | [data-scope="snackbar"][data-part="dismiss-button"]鼠标左键单击复制 |
属性
| 名称 | 说明 | 默认值 | 控件 |
|---|---|---|---|
shape可选 | Corner style; inherits the shared shape default. M3Shape | undefined | - | - |
actionLabel可选 | Label for the optional action button. string | undefined | undefined | |
actionDisabled可选 | Whether the action button is disabled. boolean | undefined | false | |
actionAutofocus可选 | Whether the action button should autofocus when rendered. boolean | undefined | false | |
actionOnNewLine可选 | Whether the action should be placed on a separate line. boolean | undefined | false | |
dismissible可选 | Whether to show a dismiss button. boolean | undefined | false | |
dismissButtonLabel可选 | Accessible label for the dismiss button. string | undefined | "Dismiss notification" |
事件2
| 名称 | 类型 | 说明 |
|---|---|---|
action | [] | - |
dismiss | [] | - |
插槽3
| 名称 | 参数 | 说明 |
|---|---|---|
default | - | Supporting text content for the snackbar. |
action | - | Optional custom action content. |
dismiss | - | Optional custom dismiss content. |
样式22
| Token | 说明 |
|---|---|
--md-snackbar-action-label-text-colorColor回退值 var(--md-sys-color-inverse-primary) | Controls action label text color. |
--md-snackbar-action-label-text-fontTypography回退值 var(--md-sys-typescale-label-large-font) | Controls action label text font. |
--md-snackbar-action-label-text-line-heightTypography回退值 var(--md-sys-typescale-label-large-line-height) | Controls action label text line height. |
--md-snackbar-action-label-text-sizeLayout回退值 var(--md-sys-typescale-label-large-size) | Controls action label text size. |
--md-snackbar-action-label-text-trackingTypography回退值 var(--md-sys-typescale-label-large-tracking) | Controls action label text tracking. |
--md-snackbar-action-label-text-weightTypography回退值 var(--md-sys-typescale-label-large-weight) | Controls action label text weight. |
--md-snackbar-container-colorColor回退值 var(--md-sys-color-inverse-surface) | Controls container color. |
--md-snackbar-container-elevationElevation回退值 var(--md-sys-elevation-level3) | Controls container elevation. |
--md-snackbar-container-padding-blockLayout回退值 1rem | Controls container padding block. |
--md-snackbar-container-padding-inline-endLayout回退值 0.5rem | Controls container padding inline end. |
--md-snackbar-container-padding-inline-startLayout回退值 1rem | Controls container padding inline start. |
--md-snackbar-container-shadow-colorColor回退值 var(--md-sys-color-shadow) | Controls container shadow color. |
--md-snackbar-container-shapeShape回退值 var(--md-shape-compact) | Controls container shape. |
--md-snackbar-icon-colorColor回退值 var(--md-sys-color-inverse-on-surface) | Controls icon color. |
--md-snackbar-icon-sizeLayout回退值 1.25rem | Controls icon size. |
--md-snackbar-supporting-text-colorColor回退值 var(--md-sys-color-inverse-on-surface) | Controls supporting text color. |
--md-snackbar-supporting-text-fontTypography回退值 var(--md-sys-typescale-body-medium-font) | Controls supporting text font. |
--md-snackbar-supporting-text-line-heightTypography回退值 var(--md-sys-typescale-body-medium-line-height) | Controls supporting text line height. |
--md-snackbar-supporting-text-sizeLayout回退值 var(--md-sys-typescale-body-medium-size) | Controls supporting text size. |
--md-snackbar-supporting-text-trackingTypography回退值 var(--md-sys-typescale-body-medium-tracking) | Controls supporting text tracking. |
--md-snackbar-supporting-text-weightTypography回退值 var(--md-sys-typescale-body-medium-weight) | Controls supporting text weight. |
--md-snackbar-with-single-line-container-heightLayout回退值 3rem | Controls with single line container height. |