Button group

Unit Switch

A unit switch that shows the converted value next to it: both numbers ship in the markup and CSS picks the one whose radio is checked.

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 unit captions through metricLabel and imperialLabel
  • the displayed numbers through metricValue and imperialValue
  • the caption under the value through caption

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

Preview

1440pxHost theme
Unit Switch — A unit switch that shows the converted value next to it: both numbers ship in the markup and CSS picks the one whose radio is checked.

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-045?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

<Buttongroup045
  metricValue="18 °C"
  imperialValue="64 °F"
  caption="weekly average"
  defaultValue="metric"
/>

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

Settings

System
defaultValue · default: metric
Accent
accent · default: theme colour
Background
background · default: theme colour
Metric value
metricValue · default: 18 °C
Imperial value
imperialValue · default: 64 °F
Caption
caption · default: weekly average

FAQ

How do I add Unit Switch 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 Unit Switch depend on?
No npm packages beyond React and Tailwind CSS.
What can I change in Unit Switch?
Adapt: the unit captions through metricLabel and imperialLabel; the displayed numbers through metricValue and imperialValue; the caption under the value through caption. Keep as installed: the local --vibeui-buttongroup-045-* palette — do not swap it for your theme tokens; both values in the markup: converting in the browser drifts from the server's rounding; the pinned width and tabular figures on the value — otherwise the cluster jumps on every switch.
Is Unit Switch 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-045.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-045-* variables. It is a server component: the conversion is done by the side that serves the page rather than in the browser — that is why the rounding and the locales do not drift apart. Both values lie in the markup, and the rule [data-vibeui-block]:has([data-unit="metric"] input:checked) [data-value="metric"]{display:inline} shows the right one. The value is set in tabular figures and has min-width:4.25rem, so "18 °C" and "64 °F" take the same space. The cluster is compact and stands next to the value rather than as a separate block: a unit without a number is meaningless.

Tags

  • buttongroup
  • units
  • readout
  • css-only
Component source

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

Loading…