Button Group

Sort Direction

Sort direction where the arrow is not swapped for another icon but rotated 180°: the same shape reversed reads more precisely than two pictures.

  • buttongroup
  • sort
  • rotate
  • table

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-028?lang=en

Сортировка: Date
Date

Сначала старые: 01.04 → 30.04Сначала новые: 30.04 → 01.04

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-028" (Sort Direction) 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-028.json

Registry item: https://vibeui.ru/r/buttongroup-028.json
Installs to: components/vibeui/buttongroup-028.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
Sort direction where the arrow is not swapped for another icon but rotated 180°: the same shape reversed reads more precisely than two pictures.

A sort direction picker built on one rotating arrow and a field caption. Zero dependencies, one file, a server component.

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

<Buttongroup028
  field="Date"
  defaultValue="desc"
  ascHint="Oldest first"
  descHint="Newest first"
  name="order"
/>

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-028-* palette — do not swap it for your theme tokens
- rotating one arrow instead of two different icons: "the same, but reversed" reads better that way
- the field name as the first cell — "ascending" without a subject is meaningless
- the rotation on the wrapper rather than the svg: a transform must not disturb the row layout
- the order example in the hint: "descending" and "newest first" land with different people
- radios inside a fieldset: direction is a single choice and the browser supplies the keyboard

## 6. You may change
- the field name through field
- the direction captions through ascLabel and descLabel
- the order examples through ascHint and descHint
- the initial direction through defaultValue, the form field name through name and the accent through accent

## 7. Rules
- There are exactly two directions: the hint rules are written on data-dir and expect no third.
- The component sorts nothing: refetching with the new order is your code's job.
- In a real table sorting is announced with aria-sort on the column header — here it is a standalone control.
- 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-028.json
https://vibeui.ru/r/buttongroup-028.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-028-*. Серверный: выбор держат radio внутри fieldset, поворот описан CSS. Стрелка обёрнута в [data-part="arrow"] и получает rotate:180deg на сегменте с data-dir="desc" — анимация трогает обёртку, а не раскладку. Название поля стоит первой неинтерактивной ячейкой той же рамки: без него «по возрастанию» повисает в воздухе. Разделители внутри рисует [data-part="segment"] + [data-part="segment"] {border-inline-start}, рамка одна — на треке, а углы обрезает overflow:hidden. Строка-подсказка показывает пример порядка и переключается правилами :has, оба текста лежат в разметке.

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 Buttongroup028Props = Omit<
  ComponentPropsWithoutRef<"fieldset">,
  "children"
> & {
  field?: string
  ascLabel?: string
  descLabel?: string
  ascHint?: string
  descHint?: string
  defaultValue?: "asc" | "desc"
  name?: string
  accent?: string
}

// Идея компонента: направление сортировки как пара сегментов, где стрелка
// не подменяется другим значком, а поворачивается на 180°. Одна и та же
// фигура, повёрнутая по выбору, читается как «то же самое, но наоборот» —
// две разные картинки такого не сообщают. Поворот описан transform у
// псевдоэлемента-обёртки стрелки, поэтому анимация не трогает раскладку.
// Название поля стоит первой, неинтерактивной ячейкой той же рамки: без
// него «по возрастанию» повисает в воздухе.
const STYLES = `
:where([data-vibeui-block="buttongroup-028"]){
--vibeui-buttongroup-028-surface:oklch(1 0 0);
--vibeui-buttongroup-028-fg:oklch(0.25 0.016 265);
--vibeui-buttongroup-028-muted:oklch(0.56 0.014 265);
--vibeui-buttongroup-028-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-028-on:oklch(0.96 0.03 265);
--vibeui-buttongroup-028-accent:oklch(0.5 0.15 265);
--vibeui-buttongroup-028-radius:0.625rem;
--vibeui-buttongroup-028-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-028"]{
box-sizing:border-box;display:inline-block;
margin:0;padding:0;border:0;
font-family:var(--vibeui-buttongroup-028-font);
}
[data-vibeui-block="buttongroup-028"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-028"] legend{
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="buttongroup-028"] [data-part="track"]{
display:flex;align-items:stretch;isolation:isolate;
border:1px solid var(--vibeui-buttongroup-028-border);
border-radius:var(--vibeui-buttongroup-028-radius);
background:var(--vibeui-buttongroup-028-surface);
overflow:hidden;
}
[data-vibeui-block="buttongroup-028"] [data-part="field"]{
display:inline-flex;align-items:center;
height:2.375rem;padding:0 0.75rem;
border-inline-end:1px solid var(--vibeui-buttongroup-028-border);
background:oklch(0.975 0.003 265);
color:var(--vibeui-buttongroup-028-fg);
font-size:0.75rem;font-weight:700;letter-spacing:0.02em;white-space:nowrap;
}
[data-vibeui-block="buttongroup-028"] [data-part="segment"]{
position:relative;z-index:0;
display:inline-flex;align-items:center;gap:0.375rem;
height:2.375rem;padding:0 0.75rem;
color:var(--vibeui-buttongroup-028-muted);
font-size:0.8125rem;font-weight:600;line-height:1;white-space:nowrap;cursor:pointer;
transition:background-color .16s ease,color .16s ease;
}
[data-vibeui-block="buttongroup-028"] [data-part="segment"] + [data-part="segment"]{
border-inline-start:1px solid var(--vibeui-buttongroup-028-border);
}
[data-vibeui-block="buttongroup-028"] input{
position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;
}
/* Одна и та же стрелка, повёрнутая на 180° — «то же, но наоборот». */
[data-vibeui-block="buttongroup-028"] [data-part="arrow"]{
display:inline-flex;transition:rotate .22s cubic-bezier(.2,.7,.3,1);
}
[data-vibeui-block="buttongroup-028"] [data-dir="desc"] [data-part="arrow"]{rotate:180deg}
[data-vibeui-block="buttongroup-028"] svg{
width:0.9375rem;height:0.9375rem;
stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;
}
[data-vibeui-block="buttongroup-028"] [data-part="segment"]:hover{color:var(--vibeui-buttongroup-028-fg)}
[data-vibeui-block="buttongroup-028"] [data-part="segment"]:has(input:checked){
z-index:1;
background:var(--vibeui-buttongroup-028-on);
color:var(--vibeui-buttongroup-028-accent);
}
[data-vibeui-block="buttongroup-028"] [data-part="segment"]:has(input:focus-visible){
z-index:2;outline:2px solid var(--vibeui-buttongroup-028-accent);outline-offset:-2px;
}
[data-vibeui-block="buttongroup-028"] [data-part="hint"]{
margin:0.4375rem 0 0;
color:var(--vibeui-buttongroup-028-muted);
font-size:0.75rem;line-height:1.4;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="buttongroup-028"] [data-part="hint"] span{display:none}
[data-vibeui-block="buttongroup-028"]:has([data-dir="asc"] input:checked) [data-part="hint"] [data-when="asc"]{display:inline}
[data-vibeui-block="buttongroup-028"]:has([data-dir="desc"] input:checked) [data-part="hint"] [data-when="desc"]{display:inline}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-028"] *{animation:none!important;transition:none!important}}
`

/**
 * Направление сортировки: одна стрелка, повёрнутая на 180°, и подпись поля.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Buttongroup028({
  field = "Дата",
  ascLabel = "По возрастанию",
  descLabel = "По убыванию",
  ascHint = "Сначала старые: 01.04 → 30.04",
  descHint = "Сначала новые: 30.04 → 01.04",
  defaultValue = "desc",
  name = "buttongroup-028",
  accent,
  className,
  style,
  ...props
}: Buttongroup028Props) {
  const palette = {
    ...(accent ? { "--vibeui-buttongroup-028-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-buttongroup-028" precedence="medium">
        {STYLES}
      </style>
      <fieldset
        {...props}
        data-vibeui-block="buttongroup-028"
        className={className}
        style={palette}
      >
        <legend>Сортировка: {field}</legend>
        <div data-part="track">
          <span data-part="field">{field}</span>
          <label data-part="segment" data-dir="asc">
            <input
              type="radio"
              name={name}
              value="asc"
              defaultChecked={defaultValue === "asc"}
            />
            <span data-part="arrow" aria-hidden="true">
              <svg viewBox="0 0 24 24">
                <path d="M12 20V4M6 10l6-6 6 6" />
              </svg>
            </span>
            {ascLabel}
          </label>
          <label data-part="segment" data-dir="desc">
            <input
              type="radio"
              name={name}
              value="desc"
              defaultChecked={defaultValue === "desc"}
            />
            <span data-part="arrow" aria-hidden="true">
              <svg viewBox="0 0 24 24">
                <path d="M12 20V4M6 10l6-6 6 6" />
              </svg>
            </span>
            {descLabel}
          </label>
        </div>
        <p data-part="hint">
          <span data-when="asc">{ascHint}</span>
          <span data-when="desc">{descHint}</span>
        </p>
      </fieldset>
    </>
  )
}