表面
托盘、凸起面板与凹槽构成所有组件共用的材质层级。
本页内容
Master UI 的所有组件都使用同几种材质。可直接用这些材质制作卡片、面板和分组,让自定义布局与组件保持一致的光影和层次。主题介绍了各层次。
托盘、凸起面板和凹槽
<div class="tray"> <div class="sheet flex flex-col gap-md p-lg"> <p class="m(0) text-sm fg-text-strong">Deployment</p> <div class="well p-md text-sm fg-text-muted">No builds are queued.</div> </div></div><div className="tray"> <div className="sheet flex flex-col gap-md p-lg"> <p className="m(0) text-sm fg-text-strong">Deployment</p> <div className="well p-md text-sm fg-text-muted">No builds are queued.</div> </div></div><div class="tray"> <div class="sheet flex flex-col gap-md p-lg"> <p class="m(0) text-sm fg-text-strong">Deployment</p> <div class="well p-md text-sm fg-text-muted">No builds are queued.</div> </div></div><template> <div class="tray"> <div class="sheet flex flex-col gap-md p-lg"> <p class="m(0) text-sm fg-text-strong">Deployment</p> <div class="well p-md text-sm fg-text-muted">No builds are queued.</div> </div> </div></template>#凸起面板
凸起面板的圆角半径为 16px,浏览器支持时采用超椭圆角。顶边带有高光,边缘用半像素轮廓勾勒,下方的短阴影逐渐淡出。凸起面板默认使用抬升层级的阴影,可按用途选用更低或更高的层级。
凸起面板的层次
<div class="sheet sheet-flat p-lg text-sm fg-text-muted">Flat</div><div class="sheet sheet-raised p-lg text-sm fg-text-muted">Raised</div><div class="sheet p-lg text-sm fg-text-muted">Lifted</div><div class="sheet sheet-floating p-lg text-sm fg-text-muted">Floating</div><> <div className="sheet sheet-flat p-lg text-sm fg-text-muted">Flat</div> <div className="sheet sheet-raised p-lg text-sm fg-text-muted">Raised</div> <div className="sheet p-lg text-sm fg-text-muted">Lifted</div> <div className="sheet sheet-floating p-lg text-sm fg-text-muted">Floating</div></><div class="sheet sheet-flat p-lg text-sm fg-text-muted">Flat</div><div class="sheet sheet-raised p-lg text-sm fg-text-muted">Raised</div><div class="sheet p-lg text-sm fg-text-muted">Lifted</div><div class="sheet sheet-floating p-lg text-sm fg-text-muted">Floating</div><template> <div class="sheet sheet-flat p-lg text-sm fg-text-muted">Flat</div> <div class="sheet sheet-raised p-lg text-sm fg-text-muted">Raised</div> <div class="sheet p-lg text-sm fg-text-muted">Lifted</div> <div class="sheet sheet-floating p-lg text-sm fg-text-muted">Floating</div></template>| 类名 | 层次 | 用途 |
|---|---|---|
sheet sheet-flat | 一圈轮廓线,无阴影 | 紧凑的列表和表格 |
sheet sheet-raised | --shadow-raised | 内容密集的表面上的小卡片 |
sheet | --shadow-lifted | 卡片和面板 |
sheet sheet-floating | --shadow-floating | 覆盖在内容上方的弹出层和菜单 |
sheet sheet-inverse | 墨色表面搭配抬升层级的阴影 | 页面上唯一用于邀请用户采取行动的表面 |
#反色
sheet-inverse 是墨色的凸起面板,在 Moonstone 中呈深色,在 Obsidian 中呈珠白色。它把主按钮的表面样式扩展到面板大小,保留相同的光照渐变和顶边高光。每页只用一处,留给需要用户采取行动的内容,例如行动号召。
面板上的文字使用反色墨色。给默认使用高强调墨色的标题添加 fg-text-inverse。默认按钮在面板上最亮,因此一眼就能看出它是操作入口;主按钮的墨色则会和面板的墨色融在一起。
反色
<section class="sheet sheet-inverse flex flex-wrap items-center justify-between gap-md p-lg"> <div class="flex flex-col gap-3xs"> <h3 class="heading heading-sm fg-text-inverse">Your trial ends in three days</h3> <p class="m(0) text-sm">Add a card to keep your projects online.</p> </div> <button type="button" class="btn btn-sm">Add a card</button></section><section className="sheet sheet-inverse flex flex-wrap items-center justify-between gap-md p-lg"> <div className="flex flex-col gap-3xs"> <h3 className="heading heading-sm fg-text-inverse">Your trial ends in three days</h3> <p className="m(0) text-sm">Add a card to keep your projects online.</p> </div> <button type="button" className="btn btn-sm">Add a card</button></section><section class="sheet sheet-inverse flex flex-wrap items-center justify-between gap-md p-lg"> <div class="flex flex-col gap-3xs"> <h3 class="heading heading-sm fg-text-inverse">Your trial ends in three days</h3> <p class="m(0) text-sm">Add a card to keep your projects online.</p> </div> <button type="button" class="btn btn-sm">Add a card</button></section><template> <section class="sheet sheet-inverse flex flex-wrap items-center justify-between gap-md p-lg"> <div class="flex flex-col gap-3xs"> <h3 class="heading heading-sm fg-text-inverse">Your trial ends in three days</h3> <p class="m(0) text-sm">Add a card to keep your projects online.</p> </div> <button type="button" class="btn btn-sm">Add a card</button> </section></template>#凹槽
凹槽低于周围表面,带有柔和的内阴影、一圈半像素轮廓线和底边下方的一道高光。输入字段、分段控件的轨道和开关都采用凹槽。
--well-radius 设置应用主题圆角缩放系数前的凹槽圆角半径。默认值为 var(--radius-control)。
凹槽
<div class="well p-lg text-sm fg-text-muted">Drop files here</div><div className="well p-lg text-sm fg-text-muted">Drop files here</div><div class="well p-lg text-sm fg-text-muted">Drop files here</div><template> <div class="well p-lg text-sm fg-text-muted">Drop files here</div></template>#托盘
托盘向内凹陷,可容纳一个或多个凸起面板。4px 的内边距让圆角相互贴合,托盘的圆角半径等于面板缩放后的圆角半径加上这段内边距。使用默认的 1.6 倍圆角缩放系数时,16px 的表面圆角半径变为 25.6px,托盘的圆角半径为 29.6px。
托盘
<div class="tray"> <p class="m(0) px-md py-sm text-xs fg-text-muted">Recent</p> <div class="sheet p-lg text-sm fg-text-body">Quarterly report.pdf</div></div><div className="tray"> <p className="m(0) px-md py-sm text-xs fg-text-muted">Recent</p> <div className="sheet p-lg text-sm fg-text-body">Quarterly report.pdf</div></div><div class="tray"> <p class="m(0) px-md py-sm text-xs fg-text-muted">Recent</p> <div class="sheet p-lg text-sm fg-text-body">Quarterly report.pdf</div></div><template> <div class="tray"> <p class="m(0) px-md py-sm text-xs fg-text-muted">Recent</p> <div class="sheet p-lg text-sm fg-text-body">Quarterly report.pdf</div> </div></template>直接放在托盘里的其他组件也需要采用凸起面板的圆角半径。在该组件的根元素上设置相应属性,凹槽用 --well-radius,代码块或面板用 --code-radius,窗口用 --window-radius,警示用 --alert-radius。属性值设为 var(--radius-surface)。托盘在圆角缩放后加上 4px 的内边距,因此默认主题和 Paper 都能保持这种圆角关系。嵌套更深的组件保留各自的圆角半径。
托盘中的凹槽
<div class="tray"> <div class="well p-lg text-sm" style="--well-radius: var(--radius-surface)"> No builds are queued. </div></div><div className="tray"> <div className="well p-lg text-sm" style={{ '--well-radius': 'var(--radius-surface)' } as React.CSSProperties}> No builds are queued. </div></div><div class="tray"> <div class="well p-lg text-sm" style="--well-radius: var(--radius-surface)"> No builds are queued. </div></div><template> <div class="tray"> <div class="well p-lg text-sm" style="--well-radius: var(--radius-surface)"> No builds are queued. </div> </div></template>#表面颜色
每个表面都通过 --surface-color 提供自己的颜色。组件会读取这个属性,用所在表面的颜色绘制环线,形成镂空效果,例如围绕角标、堆叠头像和状态圆点绘制的环线。这样,在凸起面板、托盘、凹槽、卡片或对话框中,环线会自动与表面同色。使用自定义表面时,将此属性设为它的背景色。
#使用工具类组合
这些材质也以主题令牌提供,可用 bg-surface-raised、shadow-raised、shadow-pressed 和 b-line-contour 为自定义元素应用材质。
应用材质的工具类
<div class="p-lg r-lg bg-surface-raised shadow-raised text-sm fg-text-body"> bg-surface-raised shadow-raised</div><div className="p-lg r-lg bg-surface-raised shadow-raised text-sm fg-text-body"> bg-surface-raised shadow-raised</div><div class="p-lg r-lg bg-surface-raised shadow-raised text-sm fg-text-body"> bg-surface-raised shadow-raised</div><template> <div class="p-lg r-lg bg-surface-raised shadow-raised text-sm fg-text-body"> bg-surface-raised shadow-raised </div></template>#类名
| 类名 | 说明 |
|---|---|
sheet | 凸起的表面,带 16px 圆角、半像素轮廓和抬升阴影 |
sheet-flat | 仅有一圈轮廓,无阴影,适合紧凑的列表和表格。与 sheet 一同使用 |
sheet-raised | 采用比默认低一级的凸起阴影,适合放在内容密集的表面上的小卡片。与 sheet 一同使用 |
sheet-floating | 提供浮层表面和阴影,适用于显示在内容上方的弹出层和菜单。与 sheet 一同使用 |
sheet-inverse | 采用墨色底和反相文字色的面板,用于页面中唯一引导用户采取行动的区域。与 sheet 一同使用 |
well | 带 10px 圆角和内阴影的凹陷表面 |
tray | 容纳一个或多个面板的凹陷托盘,内边距为 4px。托盘的 20px 圆角包住面板的 16px 圆角。 |
#自定义属性
| 属性 | 默认值 | 说明 |
|---|---|---|
--well-radius | var(--radius-control) | 应用圆角缩放前的圆角半径。凹槽直接置于托盘内时,使用 var(--radius-surface)。在 well 上设置 |
--surface-color | var(--color-surface-raised) | 面板的颜色。描边环读取此颜色,在下方表面上形成镂空效果。浮层面板和反色面板各自设置颜色。在 sheet 上设置 |
--surface-color | var(--color-surface-inset) | 凹槽的颜色。描边环读取此颜色,在下方表面上形成镂空效果。在 well 上设置 |
--surface-color | var(--color-surface-tray) | 托盘的颜色。描边环读取此颜色,在下方表面上形成镂空效果。在 tray 上设置 |