packages/react-aria-components/docs/examples/loading-progress.mdx
{/* Copyright 2023 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */}
import {ExampleLayout} from '@react-spectrum/docs'; export default ExampleLayout;
import docs from 'docs:react-aria-components'; import {TypeLink} from '@react-spectrum/docs'; import styles from '@react-spectrum/docs/src/docs.css'; import ProgressBar from '@react-spectrum/docs/pages/assets/component-illustrations/ProgressBar.svg'; import {ExampleCard} from '@react-spectrum/docs/src/ExampleCard'; import ChevronRight from '@spectrum-icons/workflow/ChevronRight';
A loading ProgressBar styled with Tailwind CSS.
import './tailwind.global.css';
import {ProgressBar, Label} from 'react-aria-components';
<div className="bg-linear-to-r from-blue-600 to-purple-600 p-12 rounded-lg flex justify-center">
<ProgressBar value={30} className="flex flex-col gap-3 w-56 text-white">
{({percentage, valueText}) => <>
<div className="flex">
<Label className="flex-1">Loading…</Label>
<span>{valueText}</span>
</div>
<div className="h-2 top-[50%] transform translate-y-[-50%] w-full rounded-full bg-white/40">
<div className="absolute h-2 top-[50%] transform translate-y-[-50%] rounded-full bg-white" style={{width: percentage + '%'}} />
</div>
</>}
</ProgressBar>
</div>
This example uses the tailwindcss-react-aria-components plugin. When using Tailwind v4, add it to your CSS:
@import "tailwindcss";
@plugin "tailwindcss-react-aria-components";
When using Tailwind v3, add the plugin to your tailwind.config.js instead:
module.exports = {
// ...
plugins: [
require('tailwindcss-react-aria-components')
]
};
Note: When using Tailwind v3, install tailwindcss-react-aria-components version 1.x instead of 2.x.
<ExampleCard url="../ProgressBar.html" title="ProgressBar" description="A progress bar shows progress of an operation over time."> <ProgressBar /> </ExampleCard>
</section>