shadcn.io is not affiliated with official shadcn/ui
Tabs examples · Advanced
Tabs with Badge Counts for React
Mailbox tabs with a badge after each label showing how many messages it holds.
A count on each tab tells people which view needs attention before they open it. Each TabsTrigger holds its label and a Badge: Inbox 12, Unread 5, Archived 48 and Spam 3. Use it for inboxes, task lists by status or filters with totals.
Preview
Installation
FAQ
How is the count attached to a trigger?
The Badge sits inside TabsTrigger, after the label. The trigger's own gap spaces them, so the badge needs no margin.
Why does Unread look different from the other counts?
Unread's badge uses the default variant, so it is filled. Inbox, Archived and Spam use variant="secondary".
Do these counts change when messages move?
No. The four numbers are written in the triggers, and the panels do not update them. Pass your own counts as each badge's children.
Which tab opens first?
Inbox, the default value on Tabs. The group is w-full max-w-2xl, and the list sizes to its four triggers.
Related
- Basic TabsFour horizontal tabs that switch between
- Controlled TabsThree step tabs held in state, with
- Nested TabsProfile, Settings and Billing tabs, each
- Tabs with IconsAccount, Billing, Notifications and
- Tabs with CardsFeatured, Popular and Recent tabs, each
- Tabs with FormsLogin and Register tabs that each hold a