Brutalist Progress
用于展示任务完成进度或不确定加载状态的 Brutalist 进度条组件。
Brutalist Progress 用于展示任务的确定完成进度或不确定加载状态,采用 5px rounded-base 圆角、2px 黑色描边轨道与带分隔边的主色填充条呈现。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="w-[60%]">
<wc-brutalist-progress-root
id="hero-progress"
aria-label="Task progress"
value="13"
value-text="13%"
>
<wc-brutalist-progress-track>
<wc-brutalist-progress-indicator></wc-brutalist-progress-indicator>
</wc-brutalist-progress-track>
</wc-brutalist-progress-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const el = document.querySelector('#hero-progress');
setTimeout(() => {
if (el instanceof HTMLElement)
setElementProps(el, { value: 66, valueText: '66%' });
}, 500);
</script>将于 0.3.0-rc.1 及后续版本中提供。注册包入口后可从 @proto.ui/prototypes-brutalist/progress 导入:
import { progressRoot, progressLabel, progressTrack, progressIndicator, progressValue,} from '@proto.ui/prototypes-brutalist/progress';将 Label 与 Value 置于 Track 之前即可在轨道上方自动形成左右对齐的标题行;标签默认采用 DM Sans font-sans font-medium 并保留原始大小写:
<BrutalistProgressRoot value={56} valueText="56%" className="w-full max-w-sm"> <BrutalistProgressLabel>Upload progress</BrutalistProgressLabel> <BrutalistProgressValue /> <BrutalistProgressTrack> <BrutalistProgressIndicator /> </BrutalistProgressTrack></BrutalistProgressRoot>ProgressRoot├── ProgressLabel├── ProgressValue└── ProgressTrack └── ProgressIndicator- 范围与不确定态:
value自动限制在[min, max]内(min === max时百分比为0)。省略value或将indeterminate设为true时进入不确定加载态,并向辅助技术隐藏具体当前数值。 - 被动展示:Progress 不引入键盘停靠点;更新
Root属性会自动同步所有部件暴露的value、percentage、indeterminate与status。
搭配 ProgressLabel 与 ProgressValue 在轨道上方同一行展示名称与百分比。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-brutalist-progress-root
class="w-full max-w-sm"
value="56"
value-text="56%"
>
<wc-brutalist-progress-label>
Upload progress
</wc-brutalist-progress-label>
<wc-brutalist-progress-value></wc-brutalist-progress-value>
<wc-brutalist-progress-track>
<wc-brutalist-progress-indicator></wc-brutalist-progress-indicator>
</wc-brutalist-progress-track>
</wc-brutalist-progress-root>受控进度(搭配 Slider)
Section titled “受控进度(搭配 Slider)”通过 Brutalist Slider 实时控制进度条数值。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="flex w-full max-w-sm flex-col gap-4">
<wc-brutalist-progress-root
id="controlled-progress"
value="50"
value-text="50%"
>
<wc-brutalist-progress-label>
Completion
</wc-brutalist-progress-label>
<wc-brutalist-progress-value></wc-brutalist-progress-value>
<wc-brutalist-progress-track>
<wc-brutalist-progress-indicator></wc-brutalist-progress-indicator>
</wc-brutalist-progress-track>
</wc-brutalist-progress-root>
<wc-brutalist-slider-root
id="controlled-slider"
value="50"
min="0"
max="100"
step="1"
aria-label="Progress value"
>
<wc-brutalist-slider-track>
<wc-brutalist-slider-indicator></wc-brutalist-slider-indicator>
<wc-brutalist-slider-thumb></wc-brutalist-slider-thumb>
</wc-brutalist-slider-track>
</wc-brutalist-slider-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const progress = document.querySelector('#controlled-progress');
const slider = document.querySelector('#controlled-slider');
if (
progress instanceof HTMLElement &&
slider instanceof HTMLElement
) {
slider.addEventListener('valueChange', (event) => {
const next = Math.round(event.detail.value);
setElementProps(slider, { value: next });
setElementProps(progress, {
value: next,
valueText: `${next}%`,
});
});
}
</script>在未知任务总量时展示居中描边的不确定进度段,支持平滑切换回确定态。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-brutalist-progress-root class="w-full max-w-sm" indeterminate>
<wc-brutalist-progress-label>
Building assets…
</wc-brutalist-progress-label>
<wc-brutalist-progress-value></wc-brutalist-progress-value>
<wc-brutalist-progress-track>
<wc-brutalist-progress-indicator></wc-brutalist-progress-indicator>
</wc-brutalist-progress-track>
</wc-brutalist-progress-root>| 属性 | 类型 | 默认值 |
|---|---|---|
value | number undefined | 省略(不确定态) |
min | number | 0 |
max | number | 100 |
indeterminate | boolean | false |
ariaLabel | string | '' |
valueText | string | '' |
dir | 'ltr' 'rtl' undefined | 继承上下文 |
Label、Track、Indicator 与 Value 不声明独立属性;所有部件同步暴露只读状态 value、percentage、indeterminate 与 status。