Button group

Sliding Segmented Control

A single-choice segmented control where the selected state travels rather than repaints: the thumb's movement shows where the choice came from and where it went.

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 options through options: value and label on each
  • the initial choice through defaultValue and the reaction through onChange
  • the group heading through label and the line under it through hintTemplate with the {label} placeholder

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

Preview

1440pxHost theme
Sliding Segmented Control — A single-choice segmented control where the selected state travels rather than repaints: the thumb's movement shows where the choice came from and where it went.

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/togglegroup-017?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

<Togglegroup017
  label="Range"
  defaultValue="week"
  options={[{ value: "day", label: "Day" }, { value: "week", label: "Week" }]}
  onChange={(value) => console.log(value)}
/>

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

Settings

Heading
label · default: Range
Selected
defaultValue · default: week
Accent
accent · default: theme colour
Background
background · default: theme colour

FAQ

How do I add Sliding Segmented Control 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 Sliding Segmented Control depend on?
No npm packages beyond React and Tailwind CSS.
What can I change in Sliding Segmented Control?
Adapt: the options through options: value and label on each; the initial choice through defaultValue and the reaction through onChange; the group heading through label and the line under it through hintTemplate with the {label} placeholder. Keep as installed: the local --vibeui-togglegroup-017-* palette: the component must look the same in any project; one thumb for the group instead of repainting buttons — the movement is what shows the choice moving; the segment width as a fraction of the button count: measuring by script would make the thumb jump on hydration.
Is Sliding Segmented Control 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/togglegroup-017.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

One file, zero dependencies, the --vibeui-togglegroup-017-* palette. A client component: useState holds the choice. One thumb serves the whole group and moves by translate across a fraction of the width — the animation runs on the compositor and never reflows the layout. The segment width is a fraction of the button count through the --vibeui-togglegroup-017-count variable rather than measured by script, so the server markup already carries the thumb in place and it does not jump on hydration. The buttons sit above the thumb by z-index and the label colour switches on aria-pressed. Arrow keys move focus inside the group, Home and End jump to the edges. Under prefers-reduced-motion the travel is switched off while the label colour keeps the choice visible.

Tags

  • toggle-group
  • segmented
  • animation
  • filter
Component source

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

Loading…