Button Group
Persisted Choice
A button group whose choice is honestly submitted with the form: a hidden input sits alongside, and the value is mirrored on the root as data-value.
What you can change
- the set of options through options
- the initial value through defaultValue
- the form field name through name and the accessible group name through label
A link for your AI agent: preview, code and instructions.
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this on the home page as the hero:
https://vibeui.ru/c/buttongroup-057?lang=en&theme=dark
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…
For developers
The install command lives in the “Component source” block below — a signed link that stays valid for 24 hours.
Technical notes
The component is self-contained: one file, no dependencies, its own palette in the --vibeui-buttongroup-057-* variables. It is a client component: useState holds the selected value. Buttons with aria-pressed submit nothing on their own, so an input[type=hidden] with the same value lies inside the group — a form collects it through FormData exactly like an ordinary field, and the server does not have to know anything about the buttons. The value is duplicated on the root by the data-value attribute: it is visible in the inspector and tests and styles can be written against it without looking into React state. The line under the group shows the pair that will travel to the server — that is a way to catch a drift between the look and the data. The track is a role="toolbar" with a roving tabindex: Tab stops on the group once, and the value is switched with the arrows.
Tags
- buttongroup
- form
- hidden-input
- state
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
Loading…