Button group

View Switcher

A list view switcher on toggle buttons: the state is announced through aria-pressed and the styling is selected by the same attribute, so markup and looks cannot drift apart.

React + Tailwind, shadcn-compatible: press “Copy for AI” and your Cursor or Claude Code agent installs it with the shadcn CLI.

What you can change

  • the set of views through views
  • the initial view through defaultView
  • the accessible group name through label

A link for your AI agent: preview, code and instructions.

Preview

1440pxHost theme
View Switcher — A list view switcher on toggle buttons: the state is announced through aria-pressed and the styling is selected by the same attribute, so markup and looks cannot drift apart.

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.
AI
1Pick it here

put this on the home page as the hero:

https://vibeui.club/c/buttongroup-005?lang=en&theme=dark

2Paste into the chat
3Get it in your project

Not sure where to paste it? Step-by-step guide

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

Loading…

How to use

<Buttongroup005
  views={[{ id: "list", label: "List" }, { id: "grid", label: "Grid" }]}
  defaultView="grid"
  label="List view"
  onChange={(id) => setView(id)}
/>

A sample call. The agent installs the component itself from the registry via the “Copy for AI” link.

Settings

View
defaultView · default: grid
Group name
label · default: List view
Accent
accent · default: theme colour
Background
background · default: theme colour

FAQ

How do I add View Switcher with Cursor or Claude Code?
Press “Copy for AI” on this page and paste it into your agent's chat. The instruction contains the shadcn CLI install command, the dependencies and what to keep, so the agent installs this exact component instead of recreating a lookalike.
What does View Switcher depend on?
No npm packages beyond React and Tailwind CSS.
What can I change in View Switcher?
Adapt: the set of views through views; the initial view through defaultView; the accessible group name through label. Keep as installed: the local --vibeui-buttongroup-005-* palette — do not swap it for your theme tokens; aria-pressed instead of radios: nothing is submitted, and a radio here would be a lie; styling picked by [aria-pressed="true"] — the look then cannot drift from the accessible state.
Is View Switcher free?
Yes. The preview is open without an account; with a free account you can copy up to 20 components a month.

For developers

npx shadcn@latest add https://vibeui.club/r/pro/buttongroup-005.json

This command needs a signed link: sign in and open “Component source” below — it issues a working link valid for 30 minutes. All install options

Technical notes

The component is self-contained: one file, no dependencies, its own palette in the --vibeui-buttongroup-005-* variables. It is a client component: useState holds the current view and onChange hands it outwards. Radios are deliberately not used here: the value is not submitted by a form, it changes the presentation in place — this is a set of toggle buttons with aria-pressed. The style of a pressed button is picked by the button[aria-pressed="true"] selector, so the accessible state and the look cannot drift apart. The icons are inline SVGs on currentColor, and on the active button they are repainted into the accent; the active state is carried by a surface and a shadow as well, not by colour alone. The group is a role="toolbar" with a roving tabindex: Tab stops on it once, and the view is switched inside with the arrows.

Tags

  • buttongroup
  • toggle
  • view
  • aria-pressed
Component source

The same file your agent installs. Here in case you would rather copy it by hand.

Loading…