ProgressBar 是 WordPress 组件库中的一个简单水平进度条组件,支持确定性和不确定性两种模式。开发者可以通过传递 value 属性控制进度值,或使用 className 自定义样式。
import { ProgressBar } from '@wordpress/components';
const MyLoadingComponent = () => {
return <ProgressBar />;
};
const MyLoadingComponent = ( { progress } ) => {
return <ProgressBar value={ progress } />;
};
const MyLoadingComponent = () => {
return <ProgressBar className="my-custom-progress-bar" />;
};A simple horizontal progress bar component.
Supports two modes: determinate and indeterminate. A progress bar is determinate when a specific progress value has been specified (from 0 to 100), and indeterminate when a value hasn’t been specified.
Basic usage:
import { ProgressBar } from '@wordpress/components';
const MyLoadingComponent = () => {
return <ProgressBar />;
};
You can also make it determinate by passing a value (from 0 to 100) representing the progress:
import { ProgressBar } from '@wordpress/components';
const MyLoadingComponent = ( { progress } ) => {
return <ProgressBar value={ progress } />;
};
You can customize its appearance by passing a custom CSS class name to className.
.my-custom-progress-bar {
width: 100%;
}
import { ProgressBar } from '@wordpress/components';
const MyLoadingComponent = () => {
return <ProgressBar className="my-custom-progress-bar" />;
};
The component accepts the following props:
value: numberThe progress value, a number from 0 to 100.
If a value is not specified, the progress bar will be considered indeterminate.
className: stringA CSS class to apply to the underlying div element, serving as a progress bar track.
Any additional props will be passed the underlying <progress/> element.