Loader
Shows a spinning indicator while an action or a request runs and its duration is unknown.
size
type
<Loader size="lg" type="circle" />When to use
- To tell the user that a page, a panel or a field is loading and the wait has no known length.
- Inside a button or beside a short message, such as “Salvando…”.
When not to use
- A task with known progress. Use Progress.
- Content that has a known shape while it loads. Use Skeleton.
- A processing state kept in the data, such as “Processando”. Use Status badge.
- A button waiting for an action. Use the
isLoadingprop of Button.
Types
The loader has a circle and a dashed (starburst) style.
Sizes
| Size | Diameter | Use for |
|---|---|---|
sm |
12px | Inline with small text. |
md |
16px | Beside a label, inside a field. |
lg |
24px | Default. Panels and pages. |
The spinner takes the current text color. Use className to set it.
Examples
Add a message so everyone knows what is loading.
Carregando documentos…
Content
- Write the message as the action in progress: “Carregando documentos…”.
- Keep it under five words.
- Do not use “Aguarde” alone.
Accessibility
- The spinner is decorative: the
dashedSVG hasaria-hidden="true"and thecircleis a Lucide icon, which is hidden by default. - It has no role and no text. A screen reader hears nothing. Add a text message and wrap both in a container with
role="status"so it is announced politely. - Do not rely on the movement alone. Always add words for long waits.
- The spin is a continuous animation. See Known issues for reduced motion.
Code
import { Loader } from "@repo/ui/loader";
<div role="status">
<Loader size="md" />
<span>Carregando documentos…</span>
</div>;
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | "lg" | "md" | "sm" | lg | Diameter of the spinner |
type | "circle" | "dashed" | circle | Spinner style |
Known issues
| Issue | Effect |
|---|---|
Both types use animate-spin with no motion-reduce class. |
The spinner keeps spinning for users who ask for reduced motion. |
It has no role or accessible name, and aria-* props are not accepted. |
Screen readers get no signal. The caller must wrap it in a role="status" container. |
The props accept only className, type and size. |
No way to pass aria-label or data-* attributes. |
The circle type imports Loader2 from Lucide. |
The visual depends on an icon library. The dashed type is a custom SVG, so the two styles differ in stroke. |