mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-17 16:50:22 +00:00
201 lines
5.3 KiB
Text
201 lines
5.3 KiB
Text
---
|
||
sidebar_position: 4
|
||
slug: /status-bar
|
||
---
|
||
|
||
import Tabs from '@theme/Tabs';
|
||
import TabItem from '@theme/TabItem';
|
||
|
||
import UppyCdnExample from '/src/components/UppyCdnExample';
|
||
|
||
# Status bar
|
||
|
||
The `@uppy/status-bar` plugin shows upload progress and speed, estimated time,
|
||
pre- and post-processing information, and allows users to control
|
||
(pause/resume/cancel) the upload.
|
||
|
||
:::tip
|
||
|
||
Try it out together with [`@uppy/drag-drop`](/docs/drag-drop) in
|
||
[StackBlitz](https://stackblitz.com/edit/vitejs-vite-yzbujq?file=main.js/g)
|
||
|
||
:::
|
||
|
||
## When should I use it?
|
||
|
||
When you use the [Dashboard](/docs/dashboard) it’s already included by default.
|
||
This plugin is published separately but made specifically for the Dashboard. You
|
||
can still use it without it but it may need some (CSS) tweaking for your use
|
||
case.
|
||
|
||
## Install
|
||
|
||
<Tabs>
|
||
<TabItem value="npm" label="NPM" default>
|
||
|
||
```shell
|
||
npm install @uppy/status-bar
|
||
```
|
||
|
||
</TabItem>
|
||
|
||
<TabItem value="yarn" label="Yarn">
|
||
|
||
```shell
|
||
yarn add @uppy/status-bar
|
||
```
|
||
|
||
</TabItem>
|
||
|
||
<TabItem value="cdn" label="CDN">
|
||
<UppyCdnExample>
|
||
{`
|
||
import { Uppy, StatusBar } from "{{UPPY_JS_URL}}"
|
||
const uppy = new Uppy()
|
||
uppy.use(StatusBar, { target: '#status-bar' })
|
||
`}
|
||
</UppyCdnExample>
|
||
</TabItem>
|
||
</Tabs>
|
||
|
||
## Use
|
||
|
||
```js showLineNumbers
|
||
import Uppy from '@uppy/core';
|
||
import StatusBar from '@uppy/status-bar';
|
||
|
||
import '@uppy/core/dist/style.min.css';
|
||
import '@uppy/status-bar/dist/style.min.css';
|
||
|
||
new Uppy().use(StatusBar, { target: '#status-bar' });
|
||
```
|
||
|
||
## API
|
||
|
||
### Options
|
||
|
||
#### `id`
|
||
|
||
A unique identifier for this Status Bar (`string`, default: `'StatusBar'`).
|
||
|
||
Use this if you need to add several StatusBar instances.
|
||
|
||
#### `target`
|
||
|
||
DOM element, CSS selector, or plugin to mount the Status Bar into (`Element`,
|
||
`string`, `UIPlugin`, default: `'body'`).
|
||
|
||
#### `hideAfterFinish`
|
||
|
||
Hide the Status Bar after the upload is complete (`boolean`, default: `true`).
|
||
|
||
#### `showProgressDetails`
|
||
|
||
Display remaining upload size and estimated time (`boolean`, default: `false`)
|
||
|
||
:::note
|
||
|
||
`false`: Uploading: 45%
|
||
|
||
`true`: Uploading: 45%・43 MB of 101 MB・8s left
|
||
|
||
:::
|
||
|
||
#### `hideUploadButton`
|
||
|
||
Hide the upload button (`boolean`, default: `false`).
|
||
|
||
Use this if you are providing a custom upload button somewhere, and using the
|
||
`uppy.upload()` API.
|
||
|
||
#### `hideRetryButton`
|
||
|
||
Hide the retry button (`boolean`, default: `false`).
|
||
|
||
Use this if you are providing a custom retry button somewhere, and using the
|
||
`uppy.retryAll()` or `uppy.retryUpload(fileID)` API.
|
||
|
||
#### `hidePauseResumeButton`
|
||
|
||
Hide pause/resume buttons (for resumable uploads, via [tus](http://tus.io), for
|
||
example) (`boolean`, default: `false`).
|
||
|
||
Use this if you are providing custom cancel or pause/resume buttons somewhere,
|
||
and using the `uppy.pauseResume(fileID)` or `uppy.removeFile(fileID)` API.
|
||
|
||
#### `hideCancelButton`
|
||
|
||
Hide the cancel button (`boolean`, default: `false`).
|
||
|
||
Use this if you are providing a custom retry button somewhere, and using the
|
||
`uppy.cancelAll()` API.
|
||
|
||
#### `doneButtonHandler`
|
||
|
||
Status Bar will render a “Done” button in place of pause/resume/cancel buttons,
|
||
once the upload/encoding is done (`Function`, default: `null`).
|
||
|
||
The behaviour of this “Done” button is defined by the handler function — can be
|
||
used to close file picker modals or clear the upload state. This is what the
|
||
Dashboard plugin, which uses Status Bar internally, sets:
|
||
|
||
```js
|
||
const doneButtonHandler = () => {
|
||
this.uppy.reset();
|
||
this.requestCloseModal();
|
||
};
|
||
```
|
||
|
||
#### `locale`
|
||
|
||
```js
|
||
export default {
|
||
strings: {
|
||
// Shown in the status bar while files are being uploaded.
|
||
uploading: 'Uploading',
|
||
// Shown in the status bar once all files have been uploaded.
|
||
complete: 'Complete',
|
||
// Shown in the status bar if an upload failed.
|
||
uploadFailed: 'Upload failed',
|
||
// Shown in the status bar while the upload is paused.
|
||
paused: 'Paused',
|
||
// Used as the label for the button that retries an upload.
|
||
retry: 'Retry',
|
||
// Used as the label for the button that cancels an upload.
|
||
cancel: 'Cancel',
|
||
// Used as the label for the button that pauses an upload.
|
||
pause: 'Pause',
|
||
// Used as the label for the button that resumes an upload.
|
||
resume: 'Resume',
|
||
// Used as the label for the button that resets the upload state after an upload
|
||
done: 'Done',
|
||
// When `showProgressDetails` is set, shows the number of files that have been fully uploaded so far.
|
||
filesUploadedOfTotal: {
|
||
0: '%{complete} of %{smart_count} file uploaded',
|
||
1: '%{complete} of %{smart_count} files uploaded',
|
||
},
|
||
// When `showProgressDetails` is set, shows the amount of bytes that have been uploaded so far.
|
||
dataUploadedOfTotal: '%{complete} of %{total}',
|
||
// When `showProgressDetails` is set, shows an estimation of how long the upload will take to complete.
|
||
xTimeLeft: '%{time} left',
|
||
// Used as the label for the button that starts an upload.
|
||
uploadXFiles: {
|
||
0: 'Upload %{smart_count} file',
|
||
1: 'Upload %{smart_count} files',
|
||
},
|
||
// Used as the label for the button that starts an upload, if another upload has been started in the past
|
||
// and new files were added later.
|
||
uploadXNewFiles: {
|
||
0: 'Upload +%{smart_count} file',
|
||
1: 'Upload +%{smart_count} files',
|
||
},
|
||
upload: 'Upload',
|
||
retryUpload: 'Retry upload',
|
||
xMoreFilesAdded: {
|
||
0: '%{smart_count} more file added',
|
||
1: '%{smart_count} more files added',
|
||
},
|
||
showErrorDetails: 'Show error details',
|
||
},
|
||
};
|
||
```
|