Active status toggle
Shows whether a record is active and offers a button to switch it, built for table cells and dense admin rows.
Ativo
<ActiveStatusToggle showBadge />The component is controlled: it shows isActive and calls onToggle. The app
sends the request, then updates isActive. All visible text comes from
labels, so the package stays free of translations.
When to use
- In a table row or a card header where an admin activates or deactivates a record, such as a customer or a user.
- When the current status and the opposite action should sit side by side.
When not to use
- A setting inside a form. Use Switch or Checkbox.
- A status that is only displayed. Use Badge.
- An action that deletes or cannot be undone. Use Button with the
criticalvariant and a confirmation Dialog.
States
Active, inactive, saving and disabled.
Ativo
Inativo
Ativo
Inativo
| State | What the user sees |
|---|---|
| Active | A green “Ativo” badge and a “Desativar” button that turns red on hover. |
| Inactive | A red “Inativo” badge and an “Ativar” button that turns green on hover. |
| Loading | The button shows a spinner and is disabled until the request ends. |
| Disabled | The button is disabled, for users without permission. |
Examples
Without the badge
Hide the status when the row already shows it.
Content
labels.activeandlabels.inactivename the status: “Ativo”, “Inativo”.labels.activateandlabels.deactivatename the action as a verb: “Ativar”, “Desativar”.ariaLabelnames the action and the record: “Desativar cliente Banco Alfa S.A.”. Without the record, a table full of identical buttons is ambiguous.- Keep the visible action text inside
ariaLabel, so voice control users can say what they see.
Accessibility
- The action is a native
buttonwithtype="button", reachable withTaband activated withEnterorSpace. ariaLabelreplaces the visible text as the accessible name. Always include the record name.- The icons are
aria-hidden. The status badge is plain text, so screen readers read it before the button. - The component does not announce the change. If the status is not obvious after the request ends, show a toast.
- The button is 32px high (
xxs), above the 24px minimum.
Code
import { ActiveStatusToggle } from "@repo/ui/active-status-toggle";
<ActiveStatusToggle
ariaLabel={`${isActive ? "Desativar" : "Ativar"} cliente ${customer.name}`}
isActive={isActive}
isLoading={isPending}
labels={{
activate: "Ativar",
active: "Ativo",
deactivate: "Desativar",
inactive: "Inativo",
}}
onToggle={handleToggle}
/>;
Props
ActiveStatusToggle| Prop | Type | Default | Description |
|---|---|---|---|
ariaLabel | string | — | Accessible name of the button. Name the action and the record |
disabled | boolean | false | Disables the button |
isActive | boolean | — | Current status. The button offers the opposite action |
isLoading | boolean | false | Shows a spinner on the button while the change is saved |
labels | { active: string; inactive: string; activate: string; deactivate: string } | — | All visible text: `active`, `inactive`, `activate` and `deactivate` |
onToggle | () => void | — | Called when the button is pressed |
showBadge | boolean | true | Shows the status badge before the button |
Other props| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Extra class for the wrapper, for layout only. |
Known issues
| Issue | Effect |
|---|---|
The hover fills are hover:bg-success/10 and hover:bg-critical/10. |
Translucent fills, against the no-transparency rule. The tint changes with the surface behind it. |
The inactive badge uses the legacy destructive variant. |
It maps to error today, but depends on the legacy variant map in Badge. |
| It is used only in the admin app and has no tests or documentation in tech-docs. | Behavior is defined only by the source. |
The ghost button hover color is overridden with a class, on top of the button’s own hover mix. |
Two hover styles compete, and the result can differ by theme. |