Button Group

Map Zoom Rail

A floating map control rail: zoom with a level scale and geolocation are separated by a gap rather than a line, so the finger cannot miss.

  • buttongroup
  • map
  • overlay
  • vertical

Preview

1440pxHost theme

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.

put this in the header: https://vibeui.ru/c/buttongroup-025?lang=en

Уровень приближения 4 из 6
Show the full instructions

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

# Install and place "buttongroup-025" (Map Zoom Rail) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/buttongroup-025.json

Registry item: https://vibeui.ru/r/buttongroup-025.json
Installs to: components/vibeui/buttongroup-025.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
A floating map control rail: zoom with a level scale and geolocation are separated by a gap rather than a line, so the finger cannot miss.

A floating map zoom rail with the level scale inside the cluster. Zero dependencies, one file, a server component.

## 3. How to use it
import { Buttongroup025 } from "@/components/vibeui/buttongroup-025"

<Buttongroup025 level={4} minLevel={1} maxLevel={6} label="Map controls" />

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-buttongroup-025-* palette — do not swap it for your theme tokens
- the rail's own light fill and shadow: over a map tile transparent buttons are unreadable
- the gap between zoom and geolocation — different meanings pressed together catch missed taps
- the level text under clip-path: a scale of ticks does not exist for a screen reader
- disabled at the ends of the range: a live "plus" at maximum zoom is a lie
- aria-label on the icon buttons — unnamed they are announced as "button"

## 6. You may change
- the current level through level
- the scale bounds through minLevel and maxLevel
- the accessible group name through label
- the active tick and ring colour through accent

## 7. Rules
- The backdrop is a decorative gradient standing in for a map: in a project a real layer replaces it.
- The buttons carry no onClick: your map performs the zoom, the component shows the state.
- Beyond eight ticks the scale stops being readable — prefer a number then.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/buttongroup-025.json
https://vibeui.ru/r/buttongroup-025.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-025-*. Серверный: хуков нет, уровень приходит пропсом и зажимается в диапазон minLevel..maxLevel. Группа лежит поверх подложки, поэтому несёт собственную светлую заливку и двойную тень: без них значки растворяются в любом снимке карты. Внутри две сцепки — зум и «моё положение» — разделены gap:0.5rem: разный смысл нельзя ставить вплотную. Уровень показан вертикальной шкалой делений между «плюсом» и «минусом»; она сверстана flex-direction:column-reverse, чтобы первый тик рисовался снизу. Текст «Уровень приближения N из M» лежит под clip-path — шкала для скринридера не существует.

Component source

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

import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Buttongroup025Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  level?: number
  minLevel?: number
  maxLevel?: number
  label?: string
  accent?: string
}

// Идея компонента: плавающая колонка управления картой. Группа лежит поверх
// подложки, поэтому у неё есть собственная светлая заливка и тень: без них
// значки растворяются в любом снимке. Внутри два блока — зум и «моё
// положение» — разделены зазором, а не линией: разный смысл нельзя ставить
// вплотную, иначе палец промахивается мимо цели. Текущий уровень зума
// показан вертикальной шкалой из делений между «плюсом» и «минусом»: это
// не отдельный элемент, а ячейка той же сцепки.
const STYLES = `
:where([data-vibeui-block="buttongroup-025"]){
--vibeui-buttongroup-025-map:oklch(0.93 0.02 150);
--vibeui-buttongroup-025-road:oklch(0.99 0.004 150);
--vibeui-buttongroup-025-surface:oklch(1 0 0);
--vibeui-buttongroup-025-fg:oklch(0.26 0.016 265);
--vibeui-buttongroup-025-muted:oklch(0.55 0.014 265);
--vibeui-buttongroup-025-border:oklch(0.9 0.006 265);
--vibeui-buttongroup-025-accent:oklch(0.55 0.16 250);
--vibeui-buttongroup-025-radius:0.625rem;
--vibeui-buttongroup-025-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-025"]{
box-sizing:border-box;position:relative;
display:flex;align-items:flex-start;justify-content:flex-end;
width:100%;max-width:20rem;min-height:12rem;padding:0.75rem;
border-radius:1rem;overflow:hidden;
background:
linear-gradient(115deg,transparent 46%,var(--vibeui-buttongroup-025-road) 46% 49%,transparent 49%),
linear-gradient(20deg,transparent 62%,var(--vibeui-buttongroup-025-road) 62% 65%,transparent 65%),
var(--vibeui-buttongroup-025-map);
font-family:var(--vibeui-buttongroup-025-font);
}
[data-vibeui-block="buttongroup-025"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-025"] [data-part="rail"]{
display:flex;flex-direction:column;gap:0.5rem;
}
[data-vibeui-block="buttongroup-025"] [data-part="stack"]{
display:flex;flex-direction:column;isolation:isolate;
border-radius:var(--vibeui-buttongroup-025-radius);
background:var(--vibeui-buttongroup-025-surface);
box-shadow:0 1px 2px oklch(0.2 0.03 265 / 20%),0 6px 16px oklch(0.2 0.03 265 / 14%);
}
[data-vibeui-block="buttongroup-025"] button{
appearance:none;cursor:pointer;font:inherit;
position:relative;z-index:0;
display:inline-flex;align-items:center;justify-content:center;
width:2.375rem;height:2.375rem;
border:0;background:transparent;
color:var(--vibeui-buttongroup-025-muted);
transition:background-color .16s ease,color .16s ease;
}
[data-vibeui-block="buttongroup-025"] [data-part="stack"] button + button{
border-block-start:1px solid var(--vibeui-buttongroup-025-border);
}
[data-vibeui-block="buttongroup-025"] svg{
width:1.0625rem;height:1.0625rem;
stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;
}
[data-vibeui-block="buttongroup-025"] button:hover:not(:disabled){
background:oklch(0.965 0.005 265);color:var(--vibeui-buttongroup-025-fg);
}
[data-vibeui-block="buttongroup-025"] button:disabled{opacity:.35;cursor:not-allowed}
[data-vibeui-block="buttongroup-025"] button:focus-visible{
z-index:1;outline:2px solid var(--vibeui-buttongroup-025-accent);outline-offset:-2px;
}
[data-vibeui-block="buttongroup-025"] [data-part="stack"] :first-child{
border-start-start-radius:var(--vibeui-buttongroup-025-radius);
border-start-end-radius:var(--vibeui-buttongroup-025-radius);
}
[data-vibeui-block="buttongroup-025"] [data-part="stack"] :last-child{
border-end-start-radius:var(--vibeui-buttongroup-025-radius);
border-end-end-radius:var(--vibeui-buttongroup-025-radius);
}
/* Шкала уровня — ячейка сцепки, а не подпись сбоку. */
[data-vibeui-block="buttongroup-025"] [data-part="scale"]{
display:flex;flex-direction:column-reverse;align-items:center;justify-content:center;gap:2px;
padding:0.375rem 0;
border-block:1px solid var(--vibeui-buttongroup-025-border);
}
[data-vibeui-block="buttongroup-025"] [data-part="tick"]{
width:0.875rem;height:2px;border-radius:1px;
background:oklch(0.88 0.008 265);
}
[data-vibeui-block="buttongroup-025"] [data-tick="on"]{background:var(--vibeui-buttongroup-025-accent)}
[data-vibeui-block="buttongroup-025"] [data-part="level"]{
position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-025"] *{animation:none!important;transition:none!important}}
`

/**
 * Плавающая колонка зума карты: сцепка со шкалой уровня и кнопкой геолокации.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Buttongroup025({
  level = 4,
  minLevel = 1,
  maxLevel = 6,
  label = "Управление картой",
  accent,
  className,
  style,
  ...props
}: Buttongroup025Props) {
  const current = Math.min(maxLevel, Math.max(minLevel, level))
  const ticks = Array.from(
    { length: maxLevel - minLevel + 1 },
    (_, offset) => minLevel + offset,
  )

  const palette = {
    ...(accent ? { "--vibeui-buttongroup-025-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-buttongroup-025" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="buttongroup-025"
        className={className}
        style={palette}
      >
        <div data-part="rail" role="group" aria-label={label}>
          <div data-part="stack">
            <button
              type="button"
              disabled={current === maxLevel}
              aria-label="Приблизить"
            >
              <svg viewBox="0 0 24 24" aria-hidden="true">
                <path d="M12 5v14M5 12h14" />
              </svg>
            </button>
            <div data-part="scale">
              {ticks.map((tick) => (
                <span
                  key={tick}
                  data-part="tick"
                  data-tick={tick <= current ? "on" : "off"}
                  aria-hidden="true"
                />
              ))}
              <span data-part="level">
                Уровень приближения {current} из {maxLevel}
              </span>
            </div>
            <button
              type="button"
              disabled={current === minLevel}
              aria-label="Отдалить"
            >
              <svg viewBox="0 0 24 24" aria-hidden="true">
                <path d="M5 12h14" />
              </svg>
            </button>
          </div>
          <div data-part="stack">
            <button type="button" aria-label="Показать моё положение">
              <svg viewBox="0 0 24 24" aria-hidden="true">
                <path d="M12 3v3M12 18v3M3 12h3M18 12h3M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8" />
              </svg>
            </button>
          </div>
        </div>
      </div>
    </>
  )
}