Spinner
A spinner shows that a short task is running, such as saving a form or loading a list.
When to use
Section titled “When to use”- Use it inside a button while its action runs, with the button disabled and its label in the present tense (“Menyimpan…”).
- Use it for a short wait with a label beside it, such as “Memuat data rilis”.
- Use a Skeleton when you know the shape of the content that is loading, and a Progress bar when you know how far the task has come.
Memuat data rilis
Memuat data rilis
Anatomy
Section titled “Anatomy”- 1Track
- 2Spinning arc
A 16px Lucide Loader2 icon (size-4) turning with animate-spin, in the current text color.
Variants
Section titled “Variants”There is one style. Change the size with a size-* class, such as size-6 for a page that is loading.
| React | Vue | Flutter | Type | Default | Use |
|---|---|---|---|---|---|
aria-label |
aria-label |
label (Semantics) |
text | Loading |
What is loading, such as “Menyimpan”. |
className |
class |
SizedBox.square(dimension:) |
class | size-4 |
The size. |
import { Button } from "@/components/ui/button"import { Spinner } from "@/components/ui/spinner"
export default function SpinnerDemo() { return ( <div className="flex flex-wrap items-center gap-6"> <Button disabled> <Spinner aria-label="Menyimpan" /> Menyimpan… </Button> <div className="flex items-center gap-2 text-sm text-muted-foreground"> <Spinner aria-label="Memuat data rilis" /> Memuat data rilis </div> </div> )}<script setup lang="ts">import { Button } from "@/components/ui/button"import { Spinner } from "@/components/ui/spinner"</script>
<template> <div class="flex flex-wrap items-center gap-6"> <Button disabled> <Spinner aria-label="Menyimpan" /> Menyimpan… </Button> <div class="flex items-center gap-2 text-sm text-muted-foreground"> <Spinner aria-label="Memuat data rilis" /> Memuat data rilis </div> </div></template>import 'package:flutter/material.dart';import 'package:shadcn_ui/shadcn_ui.dart';
// shadcn_ui has no spinner: a 16px CircularProgressIndicator in the primary color stands in.class Spinner extends StatelessWidget { const Spinner({super.key, required this.label, this.color});
final String label; final Color? color;
@override Widget build(BuildContext context) { return Semantics( label: label, liveRegion: true, child: SizedBox.square( dimension: 16, child: CircularProgressIndicator(strokeWidth: 2, color: color ?? ShadTheme.of(context).colorScheme.primary), ), ); }}
class SpinnerDemo extends StatelessWidget { const SpinnerDemo({super.key});
@override Widget build(BuildContext context) { final theme = ShadTheme.of(context); return Wrap( spacing: 24, runSpacing: 12, crossAxisAlignment: WrapCrossAlignment.center, children: [ ShadButton( enabled: false, leading: Spinner(label: 'Menyimpan', color: theme.colorScheme.primaryForeground), child: const Text('Menyimpan…'), ), Row( mainAxisSize: MainAxisSize.min, spacing: 8, children: [ const Spinner(label: 'Memuat data rilis'), Text('Memuat data rilis', style: theme.textTheme.muted), ], ), ], ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/spinner.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/spinner.jsonAccessibility
Section titled “Accessibility”- It has
role="status"; give it anaria-labelthat says what is happening. - It keeps turning when
prefers-reduced-motionis on: the turning is the only sign that the task is still running. - When the task ends, replace it with the result, such as a toast or the loaded list.
