Card Button
A clickable card for items such as tasks and for create-new actions, with a title, optional details and a footer row.
type
variant
<CardButton title="Revisar contestação" variant="solid" />When to use
- To show an item the user opens with one click: a task in a case, a reason in a list of options.
- To offer a “create new” action next to existing items, using the
dashedvariant. - When the card has a few lines of content: a title, a note and a status.
When not to use
- A plain action. Use Button.
- Content with several separate actions inside. Use Card and put real buttons in it. A card button is one button, so nested controls are invalid.
- Choosing an option that stays selected. Use Radio group or Checkbox.
- Navigation to a page. Wrap it in the app’s
CustomLinkor use a link styled as a card, so the destination is a real link.
Variants
| Variant | Use for |
|---|---|
solid |
Default. An existing item, with a shadow and fill. |
dashed |
A create-new action, with a dashed border. |
Layout
The card is 120px high and between 220px and 300px wide. Replace each limit
with a Tailwind class through heightClassName, minWidthClassName,
maxWidthClassName and widthClassName. The title row, the middle row and the
bottom row are optional. topRow replaces the title.
In a grid of options, remove the width limits.
States
Hover changes the fill. Disabled blocks pointer events, shows the not-allowed cursor and dims the card.
Content
- The title is the name of the item or the action: “Revisar contestação”, “Criar tarefa de recurso”. It truncates to one line.
- The middle row holds at most two lines of detail, such as the process number or a note.
- The bottom row holds status and small signs, such as a tag and a chevron.
- Create-new cards start with a plus icon and a verb.
Do and don’t
Accessibility
- It renders a native
<button type="button">, so Enter and Space activate it and the accessible name comes from its content. - Disabled sets both
disabledandaria-disabled. A disabled card cannot receive focus. - Do not put buttons or links inside the card. Interactive content nested in a button is invalid HTML and breaks keyboard and screen reader behavior.
- Keyboard focus has no custom style. See Known issues.
- The card is at least 48px high in every product use, above the 24px minimum.
Code
import { CardButton } from "@repo/ui/card-button";
import { Typography } from "@repo/ui/typography";
<CardButton
bottomRow={<Typography variant="paragraphXs">Em revisão</Typography>}
middleRow={
<Typography variant="paragraphXs">
Processo 0001234-56.2024.8.26.0100
</Typography>
}
onClick={openTask}
title={<Typography variant="paragraphSm">Revisar contestação</Typography>}
/>;
<CardButton title="Criar tarefa" variant="dashed" onClick={createTask} />;
Props
| Prop | Type | Default | Description |
|---|---|---|---|
bottomRow | ReactNode | — | Footer row, such as a status tag or helper text |
className | string | — | Extra classes, for layout only |
disabled | boolean | false | Disables the card |
heightClassName | string | h-[120px] | Tailwind height class that replaces the default |
maxWidthClassName | string | max-w-[300px] | Tailwind max-width class that replaces the default |
middleRow | ReactNode | — | Content between the title and the footer |
minWidthClassName | string | min-w-[220px] | Tailwind min-width class that replaces the default |
onClick | function | — | Click handler |
title | string | — | Heading of the card |
topRow | ReactNode | — | Replaces the title when provided |
type | "button" | "submit" | "reset" | button | Native button type |
variant | "solid" | "dashed" | solid | `solid` for existing items, `dashed` for create-new actions |
widthClassName | string | "" | Tailwind width class, empty by default |
Known issues
| Issue | Effect |
|---|---|
The dashed variant uses border-old-muted-foreground/30. |
Depends on a deprecated -old token, and the border is translucent. |
The fills use bg-disabled/20, hover:bg-disabled/40 and hover:bg-disabled/30. |
The repository avoids transparency. Hover depends on the color behind the card. |
Disabled uses opacity-50 on the whole card. |
Content, tags and icons inside become low contrast instead of using the disabled tokens. |
There is no focus-visible style. |
Keyboard focus shows only the browser default outline. |
The default title is a raw <div> with text-sm font-medium, and the middle row uses text-xs. |
Text does not follow Typography tokens when the app passes a plain string. |
Size is controlled by four class-name props (heightClassName, minWidthClassName, …). |
Apps set widths with arbitrary Tailwind classes, so cards in different pages drift apart. |
The solid variant sets border but no border color. |
The stroke is whatever the global default border color is, not a design token chosen for the card. |