--- title: Timer sidebar_label: Timer --- import { StoryWithControls } from '../../../src/components/StorybookWrapper'; # Timer A live elapsed-time display that counts up from a given start time. Used to show query and dashboard load durations. Requires a startTime timestamp to function. ## Live Example ## Try It Edit the code below to experiment with the component: ```tsx live function Demo() { const [isRunning, setIsRunning] = React.useState(true); const [startTime] = React.useState(Date.now()); return (
); } ``` ## Status Variants ```tsx live function StatusVariants() { const [startTime] = React.useState(Date.now()); return (
{['success', 'warning', 'danger', 'info', 'default', 'primary', 'secondary'].map(status => (
{status}
))}
); } ``` ## Completed Timer ```tsx live function CompletedTimer() { const start = Date.now() - 5230; const end = Date.now(); return (
Query completed in ~5.2 seconds
); } ``` ## Start and Stop ```tsx live function StartStop() { const [isRunning, setIsRunning] = React.useState(false); const [startTime, setStartTime] = React.useState(null); const handleToggle = () => { if (!isRunning && !startTime) { setStartTime(Date.now()); } setIsRunning(r => !r); }; return (
); } ``` ## Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `isRunning` | `boolean` | `true` | Whether the timer is actively counting. Toggle to start/stop. | | `status` | `string` | `"success"` | Visual status of the timer badge. | | `startTime` | `number` | `1737936000000` | - | ## Import ```tsx import { Timer } from '@superset/components'; ``` --- :::tip[Improve this page] This documentation is auto-generated from the component's Storybook story. Help improve it by [editing the story file](https://github.com/apache/superset/edit/master/superset-frontend/packages/superset-ui-core/src/components/Timer/Timer.stories.tsx). :::