Vertical button groups
Five vertical action stacks: a plain stack, a narrow icon rail, a card surface, a compact list and full-width menu rows. Each is self-contained, sized, token-driven and keyboard accessible.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/button-group-verticalDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install lucide-reactCopy the source
components/ui/button-group-vertical.tsx"use client"
import type * as React from "react"
import { Archive, Copy, Trash2 } from "lucide-react"
import { cn } from "@/lib/utils"
/* Vertical button-group family: five vertical action stacks. The buttons are
stacked, the first/last element is rounded and the middle edges are shared.
The difference is in density, container and alignment: a plain stack, an icon
rail, a carded surface, a compressed list, full-width menu rows.
Color comes ONLY from semantic tokens, via alpha color-mix. Deterministic, no
motion. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
/* Base Button olcegiyle hizali: sm=h-8, md=h-9, lg=h-10, xl=h-12. */
const sizes: Record<StyledSize, string> = {
sm: "h-8 px-3 text-sm",
md: "h-9 px-4 text-sm",
lg: "h-10 px-5 text-sm",
xl: "h-12 px-6 text-base",
}
const iconSizes: Record<StyledSize, string> = {
sm: "size-8",
md: "size-9",
lg: "size-10",
xl: "size-12",
}
type Action = {
label?: React.ReactNode
icon?: React.ReactNode
onClick?: () => void
}
type GroupProps = {
className?: string
size?: StyledSize
actions?: Action[]
}
const defaultActions: Action[] = [
{ label: "Copy", icon: <Copy /> },
{ label: "Archive", icon: <Archive /> },
{ label: "Delete", icon: <Trash2 /> },
]
const item =
"relative inline-flex shrink-0 select-none items-center gap-2 font-medium whitespace-nowrap outline-none transition-colors focus-visible:z-10 focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none"
const outline =
"border border-field-border bg-background text-foreground hover:bg-secondary hover:text-secondary-foreground"
/* Stack: kenarlarini paylasan duz dikey yigin. */
export function StackButtonGroup({ className, size = "md", actions = defaultActions }: GroupProps) {
return (
<div
data-slot="styled-button-group"
role="group"
aria-label="Stacked actions"
className={cn("inline-flex flex-col isolate", className)}
>
{actions.map((action, i) => (
<button
key={i}
type="button"
onClick={action.onClick}
data-slot="styled-button-group-item"
className={cn(
item,
outline,
sizes[size],
"justify-start",
i > 0 && "-mt-px",
i === 0 && "rounded-t-lg",
i === actions.length - 1 && "rounded-b-lg"
)}
>
{action.icon}
{action.label}
</button>
))}
</div>
)
}
/* Rail: a narrow icon rail; the labels remain as aria-label. */
export function RailButtonGroup({ className, size = "md", actions = defaultActions }: GroupProps) {
return (
<div
data-slot="styled-button-group"
role="group"
aria-label="Rail actions"
className={cn(
"inline-flex flex-col items-center gap-1 rounded-xl border border-field-border bg-background p-1",
className
)}
>
{actions.map((action, i) => (
<button
key={i}
type="button"
onClick={action.onClick}
aria-label={typeof action.label === "string" ? action.label : undefined}
data-slot="styled-button-group-item"
className={cn(
item,
"justify-center rounded-lg text-muted-foreground hover:bg-secondary hover:text-secondary-foreground",
iconSizes[size]
)}
>
{action.icon ?? action.label}
</button>
))}
</div>
)
}
/* Card: yukseltilmis kart yuzeyi, satirlar arasinda ince ayirici. */
export function CardButtonGroup({ className, size = "md", actions = defaultActions }: GroupProps) {
return (
<div
data-slot="styled-button-group"
role="group"
aria-label="Card actions"
className={cn(
"inline-flex flex-col overflow-hidden rounded-xl border border-border bg-card shadow-sm",
className
)}
>
{actions.map((action, i) => (
<button
key={i}
type="button"
onClick={action.onClick}
data-slot="styled-button-group-item"
className={cn(
item,
sizes[size],
"justify-start text-card-foreground hover:bg-[color-mix(in_oklab,var(--color-foreground)_6%,transparent)]",
i > 0 && "border-t border-border"
)}
>
{action.icon}
{action.label}
</button>
))}
</div>
)
}
/* Compact: sikistirilmis yigin, dar yatay padding ve kucuk radius. */
export function CompactButtonGroup({ className, size = "md", actions = defaultActions }: GroupProps) {
return (
<div
data-slot="styled-button-group"
role="group"
aria-label="Compact actions"
className={cn(
"inline-flex flex-col gap-px rounded-md border border-field-border bg-border p-px",
className
)}
>
{actions.map((action, i) => (
<button
key={i}
type="button"
onClick={action.onClick}
data-slot="styled-button-group-item"
className={cn(
item,
sizes[size],
"justify-start rounded-sm bg-background px-2 text-foreground hover:bg-secondary hover:text-secondary-foreground"
)}
>
{action.icon}
{action.label}
</button>
))}
</div>
)
}
/* List: tam genislikli menu satirlari, ikon solda hizali. */
export function ListButtonGroup({ className, size = "md", actions = defaultActions }: GroupProps) {
return (
<div
data-slot="styled-button-group"
role="group"
aria-label="List actions"
className={cn(
"flex w-56 max-w-full flex-col rounded-lg border border-border bg-popover p-1 text-popover-foreground",
className
)}
>
{actions.map((action, i) => (
<button
key={i}
type="button"
onClick={action.onClick}
data-slot="styled-button-group-item"
className={cn(
item,
sizes[size],
"w-full justify-start rounded-md px-2 font-normal hover:bg-secondary hover:text-secondary-foreground"
)}
>
{action.icon}
{action.label}
</button>
))}
</div>
)
}Manual installs skip the @ai2/tokens theme, so add the token CSS from the theming guide or the tone colors will be missing.
Variations
5 takes on the same idea. Each is its own export, and every one accepts a size prop (sm, md, lg, xl) aligned to the base Button scale.
Stack
A plain vertical stack sharing its borders.
import { StackButtonGroup } from "@/components/ui/button-group-vertical"
<StackButtonGroup />Rail
A narrow icon rail; labels stay as aria-labels.
import { RailButtonGroup } from "@/components/ui/button-group-vertical"
<RailButtonGroup />Card
A lifted card surface with divided rows.
import { CardButtonGroup } from "@/components/ui/button-group-vertical"
<CardButtonGroup />Compact
A tight stack with hairline gaps and a small radius.
import { CompactButtonGroup } from "@/components/ui/button-group-vertical"
<CompactButtonGroup />List
Full-width menu rows with icons aligned left.
import { ListButtonGroup } from "@/components/ui/button-group-vertical"
<ListButtonGroup />ai2 Vertical button groups: 5 styled variations on the token system
The ai2 Vertical button groups are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around action buttons stacked vertically into one unit. They are free and MIT licensed, and every color comes from a semantic token, so they theme with the rest of ai2 in light and dark.
Motion runs on framer-motion: no motion library runs here; the hover and focus states are CSS transitions. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, nothing changes, because the group animates no transforms.
What is in the ai2 Vertical button groups?
5 exports in one file: Stack, Rail, Card, Compact and List. Each renders a native button and takes a size prop (sm, md, lg, xl) aligned to the base Button. They are separate from the base Button on purpose: the base keeps its clean variant, tone and size axes, while the styled layer carries the effects.
You own the file. Copy the one category file and you have all 5 variations, with no runtime dependency on ai2 itself.
Why use it
- On-system by construction: Every color resolves to an ai2 semantic token, so the buttons follow your theme in light and dark with no extra work.
- Effect without the sprawl: The decorations live in a dedicated styled file, so the base Button keeps its clean, predictable API.
- Accessible and honest: Each renders a real button element, keeps a visible focus ring, and respects prefers-reduced-motion.
Features
- Token-driven color: No hardcoded hex or oklch; the look recolors with your theme tokens.
- framer-motion: no motion library runs here; the hover and focus states are CSS transitions.
- Reduced-motion aware: Under prefers-reduced-motion, nothing changes, because the group animates no transforms.
- Size aligned to the base: Every variation takes sm, md, lg and xl matching the base Button height scale, so styled and base buttons line up in a row.
Production tips
- Use it for emphasis, not everywhere: Styled buttons draw the eye. Reserve them for the one action you want people to take on a screen, and use the base Button for the rest.
- Keep labels as verbs: The decoration adds weight, so a clear action label keeps the button scannable.
- Pick one variation per surface: The variations share a family; using two different ones in the same view competes for attention.
Works with the rest of ai2
The Vertical button groups sit alongside the base Button and the rest of the @ai2 registry. They share the same token file, so a styled action next to a base button or a badge stays visually consistent in both modes.