Glass button groups
Five frosted action groups that keep one structure and vary the glass: a light frost, a primary tint, a smoky scrim, a near-clear crystal and a lifted depth. 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-glassDependencies, the @ai2/tokens theme and the component file are installed together.
Copy the source
components/ui/button-group-glass.tsx"use client"
import type * as React from "react"
import { cn } from "@/lib/utils"
import { glassDepth } from "@/components/ui/glass"
/* Glass button-group family: five frosted action groups. The container is
translucent in every variant; the difference is in the blur step, the source of
the tint and the depth. Color comes ONLY from semantic tokens, via alpha
color-mix. Deterministic, no motion.
The surface derives from glassDepth in @ai2/glass (AGENTS.md 4.5).
This file differs from its siblings: here the glass sits on a CONTAINER rather
than a control (rounded-xl, p-1, a bar carrying three buttons edge to edge). So
there really is content behind it to diffuse and the scale can open upward:
sm..lg are used. xl is still absent - this is a bar, not a full-page overlay. */
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",
}
type Action = {
label?: React.ReactNode
icon?: React.ReactNode
onClick?: () => void
}
type GroupProps = {
className?: string
size?: StyledSize
actions?: Action[]
}
const defaultActions: Action[] = [
{ label: "Left" },
{ label: "Center" },
{ label: "Right" },
]
const item =
"relative inline-flex shrink-0 select-none items-center justify-center gap-2 rounded-md 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"
/* Shared shell: a translucent container with the buttons floating inside it. */
function GlassShell({
props,
label,
shellClassName,
itemClassName,
}: {
props: GroupProps
label: string
shellClassName: string
itemClassName: string
}) {
const { className, size = "md", actions = defaultActions } = props
return (
<div
data-slot="styled-button-group"
role="group"
aria-label={label}
className={cn(
"inline-flex items-center gap-1 rounded-xl border p-1 isolate",
shellClassName,
className
)}
>
{actions.map((action, i) => (
<button
key={i}
type="button"
onClick={action.onClick}
data-slot="styled-button-group-item"
className={cn(item, itemClassName, sizes[size])}
>
{action.icon}
{action.label}
</button>
))}
</div>
)
}
/* Frost: a neutral frosted-glass container. Depth = md (8px), the canonical default - the container's "normal" state, the same language as glass.overlay. The surface and the signature come entirely from the library. */
export function FrostButtonGroup(props: GroupProps) {
return (
<GlassShell
props={props}
label="Frost actions"
shellClassName={cn(
glassDepth.md,
"border-[color-mix(in_oklab,var(--color-foreground)_10%,transparent)]"
)}
itemClassName="text-foreground hover:bg-[color-mix(in_oklab,var(--color-foreground)_8%,transparent)]"
/>
)
}
/* Tint: an info-toned frosted-glass container. Depth = md (8px) - the same step as Frost, DELIBERATELY: the axis separating these two is hue, not depth. The tone is info: primary/brand sits on the neutral ramp (chroma ~0.005), so it would be an invisible tint. bg overrides the library's (the tint is the surface itself); the supports- variant is overridden too, otherwise the library's supports-[backdrop-filter]:bg-background/60 would take the tint back. */
export function TintButtonGroup(props: GroupProps) {
return (
<GlassShell
props={props}
label="Tint actions"
shellClassName={cn(
glassDepth.md,
"border-[color-mix(in_oklab,var(--color-info)_24%,transparent)]",
"bg-[color-mix(in_oklab,var(--color-info)_12%,transparent)] supports-[backdrop-filter]:bg-[color-mix(in_oklab,var(--color-info)_12%,transparent)]"
)}
itemClassName="text-foreground hover:bg-[color-mix(in_oklab,var(--color-info)_18%,transparent)]"
/>
)
}
/* Smoke: a dark, smoky scrim. Depth = lg (16px) - one of the two deepest steps in the file. A scrim's job is to stop what is underneath being text and turn it into texture; because the container is wide enough, that job is genuinely visible here (putting the same value on an h-5 badge would be a waste). Neutral: what separates it from Tint is the absence of hue. */
export function SmokeButtonGroup(props: GroupProps) {
return (
<GlassShell
props={props}
label="Smoke actions"
shellClassName={cn(
glassDepth.lg,
"border-[color-mix(in_oklab,var(--color-foreground)_16%,transparent)]",
"bg-[color-mix(in_oklab,var(--color-foreground)_14%,transparent)] supports-[backdrop-filter]:bg-[color-mix(in_oklab,var(--color-foreground)_14%,transparent)]"
)}
itemClassName="text-foreground hover:bg-[color-mix(in_oklab,var(--color-foreground)_12%,transparent)]"
/>
)
}
/* Crystal: an almost transparent container. Depth = sm (4px), the least diffusing in the family. It used to be blur-xl (24px), which contradicted its own name: you should be able to see through an "almost transparent" container. The inner highlight edge is no longer hand-made but the library signature itself - writing a second inset on top would erase the signature through twMerge. */
export function CrystalButtonGroup(props: GroupProps) {
return (
<GlassShell
props={props}
label="Crystal actions"
shellClassName={cn(
glassDepth.sm,
"border-[color-mix(in_oklab,var(--color-background)_70%,transparent)]"
)}
itemClassName="text-foreground hover:bg-[color-mix(in_oklab,var(--color-background)_55%,transparent)]"
/>
)
}
/* Depth: a frosted container plus a lifting shadow. Depth = lg (16px): this is the variation that leaves the plane, and under a lifted bar a real gap forms for the blur to scatter. The shadow uses drop-shadow (the filter group): writing shadow-lg on the container would silently erase the library signature in box-shadow. The same step as Smoke, DELIBERATELY - the axis separating those two is the lift (shadow), not the smoke (tint). */
export function DepthButtonGroup(props: GroupProps) {
return (
<GlassShell
props={props}
label="Depth actions"
shellClassName={cn(
glassDepth.lg,
"border-[color-mix(in_oklab,var(--color-foreground)_12%,transparent)] drop-shadow-lg"
)}
itemClassName="text-foreground shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--color-foreground)_6%,transparent)] hover:bg-[color-mix(in_oklab,var(--color-background)_75%,transparent)]"
/>
)
}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.
Frost
A light blur over a neutral translucent shell.
import { FrostButtonGroup } from "@/components/ui/button-group-glass"
<FrostButtonGroup />Tint
A primary-tinted frosted shell with a medium blur.
import { TintButtonGroup } from "@/components/ui/button-group-glass"
<TintButtonGroup />Smoke
A smoky scrim with a strong blur behind the buttons.
import { SmokeButtonGroup } from "@/components/ui/button-group-glass"
<SmokeButtonGroup />Crystal
An almost clear shell with an inner highlight edge.
import { CrystalButtonGroup } from "@/components/ui/button-group-glass"
<CrystalButtonGroup />Depth
A frosted shell lifted by a shadow for layered depth.
import { DepthButtonGroup } from "@/components/ui/button-group-glass"
<DepthButtonGroup />ai2 Glass button groups: 5 styled variations on the token system
The ai2 Glass button groups are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around frosted, translucent action groups. 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 Glass button groups?
5 exports in one file: Frost, Tint, Smoke, Crystal and Depth. 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 Glass 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.