Harbor
harbor.dev · 2 hours ago
Ready平台
浏览器已有合适的元素或功能,组件就直接使用。下方示例均可操作,无需加载脚本。
浏览器支持一排幻灯片会吸附定位,浏览器会自动添加上一张、下一张按钮以及每张幻灯片对应的圆点。
::scroll-button() ::scroll-marker scroll-snap
a1f9e2cReady7c04b1dReadye55d0a8Building点击“发布”打开模态框,打开期间焦点保持在框内。按 Esc 或点击遮罩即可关闭。打开和关闭时都有平滑过渡,关闭后焦点返回触发按钮。
<dialog> commandfor closedby @starting-style
brand-guidelines.pdf
菜单在按钮旁展开,遇到视口边缘时会改向以保持可见。按 Esc 或点击菜单外部即可关闭。
popover position-area
鼠标悬停或用键盘聚焦时,工具提示显示名称和快捷键,不妨碍点击。
popover="hint" interestfor
1.28M this week · up 12.4%
分段控件的滑块通过锚点定位,平滑滑向当前选项。图表中的柱形出现时从基线升起。
anchor-scope anchor() @starting-style
选项列表在浮动面板上打开,位置以控件为锚点,当前选项旁显示勾号。
appearance: base-select ::picker(select)
Design review
The focus ring is cut by the mask on the code panel. Should it move to the group?
Yes. The group already has the corner, so the ring follows it.
消息输入框起初只有一行,随输入增高至十行,之后在框内滚动。上方对话保持原位。
field-sizing: content
name 属性值相同的各项互斥展开。面板通过 interpolate-size 平滑过渡到各自的内容高度。
::details-content interpolate-size details[name]
滚动驱动动画读取滑块的位置,填充从轨道起点到滑块之间的部分。
view-timeline timeline-scope
自定义
颜色、圆角和阴影都来自主题令牌。调整令牌即可改变整套组件的外观,无需覆盖组件样式。
选择自定义方式伊尔瑟湖环线
6.2 km · 2 小时 10 分钟
船屋
起点 · 0.0 km
落叶松山脊
2.6 km
山顶
4.1 km
伊尔瑟湖环线
6.2 km · 2 小时 10 分钟
船屋
起点 · 0.0 km
落叶松山脊
2.6 km
山顶
4.1 km
伊尔瑟湖环线
6.2 km · 2 小时 10 分钟
船屋
起点 · 0.0 km
落叶松山脊
2.6 km
山顶
4.1 km
伊尔瑟湖环线
6.2 km · 2 小时 10 分钟
船屋
起点 · 0.0 km
落叶松山脊
2.6 km
山顶
4.1 km
themes/editorial.css51 个令牌
/* themes/editorial.css, imported after '@master/ui' */@theme { /* Type */ --font-sans: 'Iowan Old Style', Charter, Georgia, serif; --font-weight-control: 400; /* Shape: tight corners, and nothing travels */ --radius-chip: .125rem; --radius-control-sm: .125rem; --radius-control: .1875rem; --radius-control-lg: .25rem; --radius-surface: .25rem; --lift: 0px; /* Surfaces: cream paper, and newsprint at night */ --color-surface-base: light-dark(oklch(96.4% .014 84), oklch(19.5% .008 70)); --color-surface-raised: light-dark(oklch(98.6% .009 86), oklch(22.5% .009 70)); --color-surface-raised-low: var(--color-surface-raised); --color-surface-inset: light-dark(oklch(94.4% .016 84), oklch(17% .008 70)); --color-surface-inset-hover: light-dark(oklch(92.8% .018 84), oklch(15.8% .008 70)); --color-surface-chip: light-dark(oklch(93.4% .017 84), oklch(100% 0 none / .07)); --color-surface-inverse: light-dark(oklch(44% .15 27), oklch(68% .14 30)); /* Lines carry every edge */ --color-line-hair: light-dark(oklch(25% .02 60 / .14), oklch(95% .02 84 / .13)); --color-line-contour: light-dark(oklch(25% .02 60 / .3), oklch(95% .02 84 / .26)); --color-line-divider: light-dark(oklch(25% .02 60 / .22), oklch(95% .02 84 / .2)); --color-line-strong: light-dark(oklch(25% .02 60 / .5), oklch(95% .02 84 / .44)); --color-line-mark: light-dark(oklch(25% .02 60 / .75), oklch(95% .02 84 / .66)); /* Ink: warm black, and an oxblood accent */ --color-text-strong: light-dark(oklch(21% .014 55), oklch(94% .014 84)); --color-text-body: light-dark(oklch(33% .016 55), oklch(84% .014 84)); --color-text-muted: light-dark(oklch(46% .018 60), oklch(71% .014 80)); --color-text-inverse: light-dark(oklch(97.5% .01 84), oklch(18% .01 40)); --color-focus: var(--color-text-strong); --color-ink-high: var(--color-surface-inverse); --color-ink-low: var(--color-surface-inverse); --color-ink-high-hover: light-dark(oklch(49% .16 27), oklch(73% .13 30)); --color-ink-low-hover: var(--color-ink-high-hover); --color-ink-pressed: light-dark(oklch(39% .14 27), oklch(62% .14 30)); --color-ink-highlight: transparent; --color-ink-edge: transparent; /* Depth: a rule, not a shadow */ --color-highlight: transparent; --color-lip: transparent; --color-shade-1: transparent; --color-shade-2: transparent; --color-shade-3: transparent; --color-shade-4: transparent; --color-shade-5: transparent; --shadow-pressed: inset 0 0 0 1px var(--color-line-contour); --shadow-flat: 0 0 0 1px var(--color-line-contour); --shadow-raised: 0 0 0 1px var(--color-line-strong); --shadow-raised-hover: 0 0 0 1px var(--color-line-mark); --shadow-lifted: 0 0 0 1px var(--color-line-contour); --shadow-ink: 0 0 0 0 transparent; --shadow-ink-hover: 0 0 0 0 transparent; --shadow-ink-pressed: 0 0 0 0 transparent; --shadow-ink-well: 0 0 0 0 transparent; --shadow-thumb-on-ink: 0 0 0 0 transparent;} /* Circles in place of squircles */:root { --corner-shape: round; --corner-scale: 1;}themes/technical.css51 个令牌
/* themes/technical.css, imported after '@master/ui' */@theme { /* Type: load the font before selecting it */ --font-sans: 'IBM Plex Mono', ui-monospace, monospace; --font-weight-control: 500; /* Shape: square, and nothing travels */ --radius-chip: 0; --radius-control-sm: 0; --radius-control: 0; --radius-control-lg: 0; --radius-surface: 0; --lift: 0px; /* Surfaces: drafting film, and a navy console */ --color-surface-base: light-dark(oklch(96.8% .005 240), oklch(17.5% .014 250)); --color-surface-raised: light-dark(oklch(99.5% .002 240), oklch(21% .016 250)); --color-surface-raised-low: var(--color-surface-raised); --color-surface-inset: light-dark(oklch(95% .006 240), oklch(15% .014 250)); --color-surface-inset-hover: light-dark(oklch(93.5% .007 240), oklch(13.8% .014 250)); --color-surface-chip: light-dark(oklch(94% .008 240), oklch(100% 0 none / .07)); --color-surface-inverse: light-dark(oklch(52% .2 258), oklch(76% .13 236)); /* Lines: crisp, and a step cooler */ --color-line-hair: light-dark(oklch(30% .03 250 / .12), oklch(85% .05 240 / .12)); --color-line-contour: light-dark(oklch(30% .03 250 / .26), oklch(85% .05 240 / .24)); --color-line-divider: light-dark(oklch(30% .03 250 / .18), oklch(85% .05 240 / .17)); --color-line-strong: light-dark(oklch(30% .03 250 / .42), oklch(85% .05 240 / .38)); --color-line-mark: light-dark(oklch(30% .03 250 / .62), oklch(85% .05 240 / .6)); /* Ink: cobalt for what is on */ --color-text-strong: light-dark(oklch(20% .02 255), oklch(95% .01 240)); --color-text-body: light-dark(oklch(35% .02 255), oklch(82% .015 240)); --color-text-muted: light-dark(oklch(49% .02 250), oklch(69% .02 240)); --color-text-inverse: light-dark(oklch(99% 0 none), oklch(16% .02 250)); --color-focus: var(--color-surface-inverse); --color-ink-high: var(--color-surface-inverse); --color-ink-low: var(--color-surface-inverse); --color-ink-high-hover: light-dark(oklch(57% .2 258), oklch(81% .11 236)); --color-ink-low-hover: var(--color-ink-high-hover); --color-ink-pressed: light-dark(oklch(46% .19 258), oklch(70% .13 236)); --color-ink-highlight: transparent; --color-ink-edge: transparent; --color-thumb-on-high: light-dark(oklch(100% 0 none), oklch(16% .02 250)); --color-thumb-on-low: var(--color-thumb-on-high); /* Depth: one 1px line */ --color-highlight: transparent; --color-lip: transparent; --color-shade-1: transparent; --color-shade-2: transparent; --color-shade-3: transparent; --color-shade-4: transparent; --color-shade-5: transparent; --shadow-pressed: inset 0 0 0 1px var(--color-line-contour); --shadow-flat: 0 0 0 1px var(--color-line-contour); --shadow-raised: 0 0 0 1px var(--color-line-strong); --shadow-raised-hover: 0 0 0 1px var(--color-line-mark); --shadow-lifted: 0 0 0 1px var(--color-line-strong); --shadow-ink: 0 0 0 0 transparent; --shadow-ink-hover: 0 0 0 0 transparent; --shadow-ink-pressed: 0 0 0 0 transparent; --shadow-ink-well: 0 0 0 0 transparent; --shadow-thumb-on-ink: 0 0 0 0 transparent;}themes/soft.css42 个令牌
/* themes/soft.css, imported after '@master/ui' */@theme { /* Type: the font you have, a step heavier */ --font-weight-control: 520; /* Shape: controls round off to pills */ --radius-chip: .75rem; --radius-control-sm: 1rem; --radius-control: 1.1875rem; --radius-control-lg: 1.375rem; --radius-surface: 1.75rem; --lift: 1px; /* Surfaces: lavender, and plum at night */ --color-surface-base: light-dark(oklch(96.6% .016 300), oklch(20.5% .03 295)); --color-surface-raised: light-dark(oklch(99.6% .004 300), oklch(27% .035 295)); --color-surface-raised-low: light-dark(oklch(98.2% .009 300), oklch(25% .034 295)); --color-surface-inset: light-dark(oklch(94.6% .02 300), oklch(18.5% .03 295)); --color-surface-inset-hover: light-dark(oklch(93.2% .024 300), oklch(17.2% .03 295)); --color-surface-chip: light-dark(oklch(94.4% .02 300), oklch(100% 0 none / .08)); --color-surface-inverse: light-dark(oklch(55% .19 292), oklch(80% .11 292)); /* Lines: faint, and tinted */ --color-line-hair: light-dark(oklch(35% .1 295 / .08), oklch(92% .05 295 / .09)); --color-line-contour: light-dark(oklch(35% .1 295 / .12), oklch(92% .05 295 / .14)); --color-line-divider: light-dark(oklch(35% .1 295 / .1), oklch(92% .05 295 / .12)); --color-line-strong: light-dark(oklch(35% .1 295 / .2), oklch(92% .05 295 / .22)); --color-line-mark: light-dark(oklch(35% .1 295 / .34), oklch(92% .05 295 / .36)); /* Ink: violet for what is on */ --color-text-strong: light-dark(oklch(25% .05 295), oklch(95% .02 300)); --color-text-body: light-dark(oklch(40% .05 295), oklch(84% .03 300)); --color-text-muted: light-dark(oklch(51% .05 295), oklch(73% .04 300)); --color-text-inverse: light-dark(oklch(99% .005 300), oklch(20% .04 295)); --color-focus: var(--color-surface-inverse); --color-ink-high: light-dark(oklch(62% .18 292), oklch(86% .09 292)); --color-ink-low: light-dark(oklch(53% .2 290), oklch(77% .12 290)); --color-ink-high-hover: light-dark(oklch(66% .17 292), oklch(89% .08 292)); --color-ink-low-hover: light-dark(oklch(57% .19 290), oklch(81% .11 290)); --color-ink-pressed: light-dark(oklch(48% .19 290), oklch(72% .13 290)); --color-ink-edge: light-dark(oklch(46% .18 290), oklch(0% 0 none / .4)); --color-thumb-on-high: light-dark(oklch(100% 0 none), oklch(22% .04 295)); --color-thumb-on-low: light-dark(oklch(97% .01 300), oklch(20% .04 295)); /* Depth: wide, tinted shade */ --color-shade-1: light-dark(oklch(40% .12 295 / .07), oklch(5% .02 295 / .45)); --color-shade-2: light-dark(oklch(40% .12 295 / .07), oklch(5% .02 295 / .36)); --color-shade-3: light-dark(oklch(40% .12 295 / .08), oklch(5% .02 295 / .32)); --color-shade-4: light-dark(oklch(40% .12 295 / .1), oklch(5% .02 295 / .32)); --color-shade-5: light-dark(oklch(40% .12 295 / .14), oklch(5% .02 295 / .4)); --shadow-raised: inset 0 1px 0 var(--color-highlight), 0 0 0 .5px var(--color-line-contour), 0 2px 6px -2px var(--color-shade-1), 0 8px 18px -8px var(--color-shade-3); --shadow-raised-hover: inset 0 1px 0 var(--color-highlight), 0 0 0 .5px var(--color-line-strong), 0 4px 10px -3px var(--color-shade-2), 0 14px 28px -10px var(--color-shade-4); --shadow-lifted: inset 0 1px 0 var(--color-highlight), 0 0 0 .5px var(--color-line-contour), 0 6px 16px -6px var(--color-shade-2), 0 28px 60px -24px var(--color-shade-5); --shadow-ink: inset 0 1px 0 oklch(100% 0 none / .3), 0 0 0 .5px var(--color-ink-edge), 0 6px 16px -6px light-dark(oklch(50% .2 290 / .55), oklch(0% 0 none / .5)); --shadow-ink-hover: inset 0 1px 0 oklch(100% 0 none / .34), 0 0 0 .5px var(--color-ink-edge), 0 10px 22px -8px light-dark(oklch(50% .2 290 / .6), oklch(0% 0 none / .55));}themes/bold.css52 个令牌
/* themes/bold.css, imported after '@master/ui' */@theme { /* Type: the font you have, at its boldest */ --font-weight-control: 700; /* Shape: plain circular corners, and a long press */ --radius-chip: .25rem; --radius-control-sm: .375rem; --radius-control: .5rem; --radius-control-lg: .625rem; --radius-surface: .75rem; --lift: 2px; /* Surfaces: butter and white, or black */ --color-surface-base: light-dark(oklch(95.5% .04 92), oklch(16% .005 280)); --color-surface-raised: light-dark(oklch(100% 0 none), oklch(22% .006 280)); --color-surface-raised-low: var(--color-surface-raised); --color-surface-inset: light-dark(oklch(93% .045 92), oklch(14% .005 280)); --color-surface-inset-hover: light-dark(oklch(90.5% .055 92), oklch(12% .005 280)); --color-surface-chip: light-dark(oklch(92% .05 92), oklch(100% 0 none / .1)); --color-surface-inverse: oklch(87% .175 95); /* Lines: solid ink, 2px wide */ --color-line-hair: light-dark(oklch(15% 0 none / .2), oklch(96% .02 95 / .2)); --color-line-contour: light-dark(oklch(15% 0 none), oklch(96% .02 95)); --color-line-divider: light-dark(oklch(15% 0 none / .35), oklch(96% .02 95 / .3)); --color-line-strong: var(--color-line-contour); --color-line-mark: var(--color-line-contour); /* Ink: yellow for what is on, in both schemes */ --color-text-strong: light-dark(oklch(15% 0 none), oklch(97% .02 95)); --color-text-body: light-dark(oklch(22% 0 none), oklch(90% .02 95)); --color-text-muted: light-dark(oklch(38% .01 90), oklch(77% .02 95)); --color-text-inverse: oklch(15% 0 none); --color-focus: light-dark(oklch(15% 0 none), oklch(87% .175 95)); --color-ink-high: var(--color-surface-inverse); --color-ink-low: var(--color-surface-inverse); --color-ink-high-hover: oklch(90% .16 95); --color-ink-low-hover: var(--color-ink-high-hover); --color-ink-pressed: oklch(81% .17 90); --color-ink-highlight: transparent; --color-ink-edge: var(--color-line-contour); --color-thumb-on-high: oklch(15% 0 none); --color-thumb-on-low: oklch(15% 0 none); /* Depth: a hard shadow, offset */ --color-highlight: transparent; --color-lip: transparent; --color-shade-1: transparent; --color-shade-2: transparent; --color-shade-3: transparent; --color-shade-4: transparent; --color-shade-5: transparent; --shadow-pressed: inset 0 0 0 2px var(--color-line-contour); --shadow-flat: 0 0 0 2px var(--color-line-contour); --shadow-raised: 0 0 0 2px var(--color-line-contour), 3px 3px 0 2px var(--color-line-contour); --shadow-raised-hover: 0 0 0 2px var(--color-line-contour), 5px 5px 0 2px var(--color-line-contour); --shadow-lifted: 0 0 0 2px var(--color-line-contour), 6px 6px 0 2px var(--color-line-contour); --shadow-ink: var(--shadow-raised); --shadow-ink-hover: var(--shadow-raised-hover); --shadow-ink-pressed: var(--shadow-pressed); --shadow-ink-well: inset 0 0 0 2px var(--color-line-contour); --shadow-thumb-on-ink: 0 0 0 0 transparent;} /* Circles in place of squircles */:root { --corner-shape: round; --corner-scale: 1;}HTML 优先
给原生元素加一个类名,就能用上组件,因此同一份标记在纯 HTML、React、Svelte 和 Vue 中都能直接使用。浏览器用一份样式表呈现组件的材质,并根据元素自身的属性呈现各个状态。无需安装运行时,也无需在客户端进行水合。
框架组件<section class="card">
<header class="card-header">
<h3 class="card-title">Preview deployments</h3>
<p class="card-description">A URL for every pull request.</p>
<input type="checkbox" role="switch" class="switch card-action"
checked aria-label="Preview deployments">
</header>
<div class="card-body">
<label class="field">
Branch pattern
<input class="input" value="feature/*">
</label>
</div>
<footer class="card-footer">
<button type="button" class="btn btn-sm">Reset</button>
<button type="button" class="btn btn-sm btn-primary">Save</button>
</footer>
</section>export function PreviewDeployments() {
return (
<section className="card">
<header className="card-header">
<h3 className="card-title">Preview deployments</h3>
<p className="card-description">A URL for every pull request.</p>
<input type="checkbox" role="switch" className="switch card-action"
defaultChecked aria-label="Preview deployments" />
</header>
<div className="card-body">
<label className="field">
Branch pattern
<input className="input" defaultValue="feature/*" />
</label>
</div>
<footer className="card-footer">
<button type="button" className="btn btn-sm">Reset</button>
<button type="button" className="btn btn-sm btn-primary">Save</button>
</footer>
</section>
)
}<section class="card">
<header class="card-header">
<h3 class="card-title">Preview deployments</h3>
<p class="card-description">A URL for every pull request.</p>
<input type="checkbox" role="switch" class="switch card-action"
checked aria-label="Preview deployments">
</header>
<div class="card-body">
<label class="field">
Branch pattern
<input class="input" value="feature/*">
</label>
</div>
<footer class="card-footer">
<button type="button" class="btn btn-sm">Reset</button>
<button type="button" class="btn btn-sm btn-primary">Save</button>
</footer>
</section><template>
<section class="card">
<header class="card-header">
<h3 class="card-title">Preview deployments</h3>
<p class="card-description">A URL for every pull request.</p>
<input type="checkbox" role="switch" class="switch card-action"
checked aria-label="Preview deployments">
</header>
<div class="card-body">
<label class="field">
Branch pattern
<input class="input" value="feature/*">
</label>
</div>
<footer class="card-footer">
<button type="button" class="btn btn-sm">Reset</button>
<button type="button" class="btn btn-sm btn-primary">Save</button>
</footer>
</section>
</template>仅用样式表呈现
A URL for every pull request.
<div class="toast-region" role="region"
aria-label="Notifications" aria-live="polite">
<dialog open class="toast toast-success" aria-labelledby="forge-toast">
<svg class="icon toast-icon" viewBox="0 0 16 16" aria-hidden="true"
fill="none" stroke="currentColor" stroke-linecap="round">
<circle cx="8" cy="8" r="6"/>
<path d="M5 8L7.1041 9.8703A0.2 0.2 0 0 0 7.3832
9.8573L10.75 6.25"/>
</svg>
<div class="toast-body">
<p class="toast-title" id="forge-toast">Deployed to production</p>
<p class="toast-description">atlas.dev is live in 14 regions.</p>
</div>
<form method="dialog" class="toast-close">
<button class="btn btn-quiet btn-square btn-sm" aria-label="Dismiss">
<svg class="icon" viewBox="0 0 16 16" aria-hidden="true"
fill="none" stroke="currentColor" stroke-linecap="round">
<path d="M4 4L12 12"/>
<path d="M4 12L12 4"/>
</svg>
</button>
</form>
</dialog>
</div>export function DeployedToast() {
return (
<div className="toast-region" role="region"
aria-label="Notifications" aria-live="polite">
<dialog open className="toast toast-success" aria-labelledby="forge-toast">
<svg className="icon toast-icon" viewBox="0 0 16 16" aria-hidden="true"
fill="none" stroke="currentColor" strokeLinecap="round">
<circle cx="8" cy="8" r="6"/>
<path d="M5 8L7.1041 9.8703A0.2 0.2 0 0 0 7.3832
9.8573L10.75 6.25"/>
</svg>
<div className="toast-body">
<p className="toast-title" id="forge-toast">Deployed to production</p>
<p className="toast-description">atlas.dev is live in 14 regions.</p>
</div>
<form method="dialog" className="toast-close">
<button className="btn btn-quiet btn-square btn-sm" aria-label="Dismiss">
<svg className="icon" viewBox="0 0 16 16" aria-hidden="true"
fill="none" stroke="currentColor" strokeLinecap="round">
<path d="M4 4L12 12"/>
<path d="M4 12L12 4"/>
</svg>
</button>
</form>
</dialog>
</div>
)
}<div class="toast-region" role="region"
aria-label="Notifications" aria-live="polite">
<dialog open class="toast toast-success" aria-labelledby="forge-toast">
<svg class="icon toast-icon" viewBox="0 0 16 16" aria-hidden="true"
fill="none" stroke="currentColor" stroke-linecap="round">
<circle cx="8" cy="8" r="6"/>
<path d="M5 8L7.1041 9.8703A0.2 0.2 0 0 0 7.3832
9.8573L10.75 6.25"/>
</svg>
<div class="toast-body">
<p class="toast-title" id="forge-toast">Deployed to production</p>
<p class="toast-description">atlas.dev is live in 14 regions.</p>
</div>
<form method="dialog" class="toast-close">
<button class="btn btn-quiet btn-square btn-sm" aria-label="Dismiss">
<svg class="icon" viewBox="0 0 16 16" aria-hidden="true"
fill="none" stroke="currentColor" stroke-linecap="round">
<path d="M4 4L12 12"/>
<path d="M4 12L12 4"/>
</svg>
</button>
</form>
</dialog>
</div><template>
<div class="toast-region" role="region"
aria-label="Notifications" aria-live="polite">
<dialog open class="toast toast-success" aria-labelledby="forge-toast">
<svg class="icon toast-icon" viewBox="0 0 16 16" aria-hidden="true"
fill="none" stroke="currentColor" stroke-linecap="round">
<circle cx="8" cy="8" r="6"/>
<path d="M5 8L7.1041 9.8703A0.2 0.2 0 0 0 7.3832
9.8573L10.75 6.25"/>
</svg>
<div class="toast-body">
<p class="toast-title" id="forge-toast">Deployed to production</p>
<p class="toast-description">atlas.dev is live in 14 regions.</p>
</div>
<form method="dialog" class="toast-close">
<button class="btn btn-quiet btn-square btn-sm" aria-label="Dismiss">
<svg class="icon" viewBox="0 0 16 16" aria-hidden="true"
fill="none" stroke="currentColor" stroke-linecap="round">
<path d="M4 4L12 12"/>
<path d="M4 12L12 4"/>
</svg>
</button>
</form>
</dialog>
</div>
</template>仅用样式表呈现
<div class="segmented" role="radiogroup" aria-label="View">
<label class="segmented-item">
<input type="radio" class="segmented-input"
name="forge-view" value="list" checked>
List
</label>
<label class="segmented-item">
<input type="radio" class="segmented-input"
name="forge-view" value="board">
Board
</label>
<label class="segmented-item">
<input type="radio" class="segmented-input"
name="forge-view" value="timeline">
Timeline
</label>
</div>export function ViewSwitch() {
return (
<div className="segmented" role="radiogroup" aria-label="View">
<label className="segmented-item">
<input type="radio" className="segmented-input"
name="forge-view" value="list" defaultChecked />
List
</label>
<label className="segmented-item">
<input type="radio" className="segmented-input"
name="forge-view" value="board" />
Board
</label>
<label className="segmented-item">
<input type="radio" className="segmented-input"
name="forge-view" value="timeline" />
Timeline
</label>
</div>
)
}<div class="segmented" role="radiogroup" aria-label="View">
<label class="segmented-item">
<input type="radio" class="segmented-input"
name="forge-view" value="list" checked>
List
</label>
<label class="segmented-item">
<input type="radio" class="segmented-input"
name="forge-view" value="board">
Board
</label>
<label class="segmented-item">
<input type="radio" class="segmented-input"
name="forge-view" value="timeline">
Timeline
</label>
</div><template>
<div class="segmented" role="radiogroup" aria-label="View">
<label class="segmented-item">
<input type="radio" class="segmented-input"
name="forge-view" value="list" checked>
List
</label>
<label class="segmented-item">
<input type="radio" class="segmented-input"
name="forge-view" value="board">
Board
</label>
<label class="segmented-item">
<input type="radio" class="segmented-input"
name="forge-view" value="timeline">
Timeline
</label>
</div>
</template>仅用样式表呈现
当框架负责以下任一项时,就提供框架组件
体积
组件共用一套主题,各有独立样式表,多数无需脚本。选出页面用到的组件,查看构建时实测的体积。
未选择任何项
到“全部”中选择页面用到的组件。
编译后体积(kB)JS 需要其脚本JS? 脚本可选
| 样式表 | 脚本 | 编译后,kB |
|---|---|---|
| 外观 | 无 | 20.5 |
| 卡片 | 无 | 6.0 |
| 分类色 随 输入框 引入 | 无 | 5.8 |
| 图标 随 按钮 引入 | 无 | 0.3 |
| 按钮 | 无 | 11.5 |
| 输入框 | 无 | 20.0 |
| 下拉选择框 | 无 | 8.2 |
| 复选框 | 无 | 3.7 |
| 开关 | 无 | 3.3 |
| 胶囊标签 随 输入框 引入 | 无 | 7.9 |
| 标签页 | tabs.js, optional | 3.0 |
| 对话框 | drawer.js, optional | 10.3 |
| 工具提示 | 无 | 3.0 |
| 加载指示器 随 按钮 引入 | 无 | 1.2 |
| 头像 随 输入框 引入 | avatar.js, optional | 4.2 |
| 徽标 | 无 | 6.7 |
| 键帽 随 输入框 引入 | 无 | 0.9 |
16 个样式表
CSS,gzip 压缩后
18.0kB
占整个库的 21%,gzip 压缩后为 87.2 kB
编译后 116.5 kB:主题计一次,再加上 16 个样式表。 其中 6 个随其他组件一起引入。
JavaScript,gzip 压缩后
0kB
占全部行为模块的 0%,gzip 压缩后为 94.9 kB
无需脚本。所有状态均由原生元素及其属性呈现。 标记为可选的项不计入。
drawer.js可选,用于 对话框1.8 kBtabs.js可选,用于 标签页1.4 kBdist/standalone.css的方式编译,编译结果不做代码压缩,随后作为单个文件用 gzip 压缩。gzip 压缩后的体积无法直接相加,因此本页从发布文件中截取每组选中内容,分别用 gzip 压缩。base.css在项目没有重置样式时会额外增加 1.7 kB(gzip 后)。internal.js由 19 个行为共用,只计一次。1 kB 等于 1,000 字节。实测对比
分别用 Master UI 和 shadcn/ui 为六种常用组件生成生产构建,再用同一个脚本测量体积。 六个组件放在同一页,gzip 压缩后:Master UI 为 12.8 kB,基于 Base UI 的 shadcn/ui 为 149.2 kB。差距就在 JavaScript。
查看并运行基准测试| 组成部分 | 首次加载体积(gzip), kB总计CSSJS |
|---|---|
| 仅基础配置不含组件 | |
| 按钮 | |
| 卡片 | |
| 对话框 | |
| 标签页Master UI:tabs.js | |
| 下拉选择框Master UI:原生,无脚本 | |
| 工具提示 | |
| 全部六个组件11.7× (Master UI 更轻,倍数为 shadcn/ui 与 Master UI 的体积之比)6.4× (Master UI 更轻,倍数为 shadcn/ui 与 Master UI 的体积之比)10.0× (Master UI 更轻,倍数为 shadcn/ui 与 Master UI 的体积之比)4.7× (Master UI 更轻,倍数为 shadcn/ui 与 Master UI 的体积之比) |
契约
每个组件都附带一份契约,列出类名、状态、按键、适用场景和一个正确示例。智能体先阅读契约,再编写标记。检查器会标出违反契约的标记。
@master/ui/check 本页构建时开启时,珍珠色滑块滑到墨色轨道的一端,设置随即生效。
可开启或关闭的设置,切换后立即生效,无需点击保存。
<input type="checkbox" role="switch">labelof switchexclusive: sizeof switchexclusive: size:checkeddisabled状态用属性或伪类表示,禁止用类名表示状态。
文件中还有: instead · composes
settings.html初稿
<label class="check"> <input type="checkbox" class="switch switch-on" checked> Email notifications</label>终端exit 1
npx master-ui check settings.htmlsettings.html:2:3 error attribute "switch" needs role="switch" on its element.settings.html:2:3 warning unknown-class "switch-on" is not a class of switch. It has: switch, switch-sm, switch-lg.1 files checked: 1 errors, 1 warnings.行 2, 按示例重写
修改前: <input type="checkbox" class="switch switch-on" checked>修改后: <input type="checkbox" role="switch" class="switch" checked>终端exit 0
npx master-ui check settings.html1 files checked: 0 errors, 0 warnings./cn/llms.txt编写 Master UI 标记的规则,以及每个页面 Markdown 版本的链接。
/contracts.json以结构化数据提供全部契约,供生成标记的程序读取。
npx skills add master-co/ui --skill master-ui一项智能体技能,指导智能体查阅契约、检查自己编写的标记,并在浏览器中验证结果。
npx master-ui add <name>React、Svelte 和 Vue 组件以源码提供,可直接复制,也可通过 shadcn 格式的注册表获取。
组件库
组件提供可交互的预览、对应的标记和供编程智能体读取的契约。图表以二十多种形式呈现数据。区块将组件组合成产品界面的一部分,页面则搭起整个屏幕的布局框架。每一项都可以复制到自己的项目中,留作己用。
安装软件包并导入样式表,再给原生元素加上类名。每个组件都可用于纯 HTML 或任意框架。