Radio filter
A single-choice filter shown as compact badges or as tiles, with optional counts and semantic colors for statuses.
size
<RadioFilter allowDeselect label="Status da tarefa" size="badge" />When to use
- To filter a list or a table by one value, such as the status of a task.
- When the options are few and the user should see all of them at once.
- When each option can show a count.
When not to use
- A choice sent with a form. Use Radio group.
- Options with a title and a description. Use Radio card.
- Many options or a searchable list. Use Select.
- Filtering by several values at once. Use a multi-select filter from the same package.
Sizes
badge is a compact row of chips. card and cardCompact are tiles for the
main filter of a page.
Badge
Card
Compact card
| Size | Use for |
|---|---|
badge |
Status filters above a list. Scrolls with optionsClassName. |
card |
The main filter of a page. 128px square tiles. |
cardCompact |
Dense panels. 76px square tiles. |
Variants
Semantic variants apply to badge options and color the badge while it is
selected. A selected semantic badge also shows a check, so the status does not
depend on color alone. Without variant, the selected badge uses the standard
brand light fill and no check.
| Variant | Use for |
|---|---|
neutral |
Neutral options such as “Pendentes”. |
info |
Active or informational states. |
success |
Completed states. |
warning |
Skipped or paused states. |
error |
Failed states. |
States
With a visible label
Disabled
Disable the whole group with disabled, or one option with disabled in its
object.
Content
- Put “Todas” first, and use
allowDeselect={false}when one option must always stay selected. - With
allowDeselect(the default), selecting the active option again clears the filter and callsonValueChange(null). - Use
endContentfor counts. It is visual only: do not put essential information there. - Keep labels to one or two words: “Com falha”, “Concluídas”.
Accessibility
- Built on Radix Radio Group. The group is
role="radiogroup"and each option has ansr-onlyrole="radio"input inside aLabel, so the whole chip or tile is clickable. Tabenters the group at the selected option. Arrow keys move focus and selection, andSpaceselects.- Pass
labelorariaLabel. Withlabel, the group is named by it througharia-labelledby. Without it,ariaLabelis the name. - In
badgesize the focus ring is drawn around the chip when the radio has keyboard focus. endContentisaria-hidden. Counts are not read, so repeat what matters inlabel.
Code
import { RadioFilter } from "@repo/ui/filters";
<RadioFilter
allowDeselect={false}
ariaLabel="Filtrar tarefas por status"
onValueChange={setStatus}
options={[
{ label: "Todas", value: "todas" },
{ label: "Concluídas", value: "concluidas", variant: "success" },
{ label: "Com falha", value: "falha", variant: "error" },
]}
value={status}
/>;
Props
RadioFilter| Prop | Type | Default | Description |
|---|---|---|---|
allowDeselect | boolean | true | Lets the user clear the filter by selecting the active option again |
ariaLabel | string | — | Accessible name of the group when no `label` is shown |
disabled | boolean | false | Disables the whole group |
label | string | — | Visible label above the options |
onValueChange | (value: string | null) => void | — | Called with the new value, or `null` when the user clears the filter |
options | RadioFilterOption[] | — | Options with `value` and `label`, plus optional `icon`, `variant`, `endContent` and `disabled` |
size | "badge" | "card" | "cardCompact" | badge | Presentation of the options |
value | string | — | Controlled value of the selected option |
RadioFilterOption| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Value of the option. Required. |
label | string | — | Visible and accessible name of the option. Required. |
variant | "neutral" | "info" | "success" | "warning" | "error" | — | Color of the selected badge, with a check. Only for `size="badge"`. |
icon | ElementType | — | Icon before the label. |
endContent | ReactNode | — | Visual-only content after the label, such as a count. |
disabled | boolean | false | Disables this option. |
Other props: labelIcon (ElementType) adds an icon before the visible
label, and className and optionsClassName adjust layout.
Known issues
| Issue | Effect |
|---|---|
The focus ring (has-[:focus-visible]) exists only for badge size. card and cardCompact options without an icon, and every compact option, have none. |
Keyboard users cannot see which tile has focus. |
A badge option without variant has no disabled style, only cursor-pointer. |
A disabled option looks enabled. Only options with a variant get opacity-50 and a muted border. |
Disabled semantic badges use opacity-50. |
Translucent state, against the no-transparency rule. |
The badge hover uses hover:bg-disabled, the disabled fill token. |
The hover color is the same as the one that means “unavailable”. |
size="card" with an icon renders a Tile with its own styles and ignores endContent. |
Counts do not show on large icon tiles. |