Tone button groups
Five attached action groups that share one structure and vary only the semantic tone: info, success, warning, danger and muted. Each carries a data-tone attribute, is 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-toneDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install lucide-reactCopy the source
components/ui/button-group-tone.tsx"use client"
import type * as React from "react"
import { AlertTriangle, Ban, CheckCircle2, Circle, Info } from "lucide-react"
import { cn } from "@/lib/utils"
/* Tone button-group family: five semantically toned action groups. The structure is the same in every variant (an attached row sharing edges plus a leading icon that states the tone); the difference is ONLY the colour tone: info, success, warning, danger, muted. Colour comes ONLY from semantic tokens, alpha via 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",
}
type Action = {
label?: React.ReactNode
icon?: React.ReactNode
onClick?: () => void
}
type GroupProps = {
className?: string
size?: StyledSize
actions?: Action[]
}
const defaultActions: Action[] = [
{ label: "View" },
{ label: "Edit" },
{ label: "Share" },
]
const item =
"relative inline-flex shrink-0 select-none items-center justify-center gap-2 border 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: an attached row with a tone icon on the first element. */
function ToneShell({
props,
tone,
label,
icon,
itemClassName,
}: {
props: GroupProps
tone: string
label: string
icon: React.ReactNode
itemClassName: string
}) {
const { className, size = "md", actions = defaultActions } = props
return (
<div
data-slot="styled-button-group"
data-tone={tone}
role="group"
aria-label={label}
className={cn("inline-flex isolate", className)}
>
{actions.map((action, i) => (
<button
key={i}
type="button"
onClick={action.onClick}
data-slot="styled-button-group-item"
data-tone={tone}
className={cn(
item,
itemClassName,
sizes[size],
i > 0 && "-ml-px",
i === 0 && "rounded-l-lg",
i === actions.length - 1 && "rounded-r-lg"
)}
>
{i === 0 ? (action.icon ?? icon) : action.icon}
{action.label}
</button>
))}
</div>
)
}
/* Info: bilgilendirici mavi ton, yumusak dolgu. */
export function InfoButtonGroup(props: GroupProps) {
return (
<ToneShell
props={props}
tone="info"
label="Info actions"
icon={<Info />}
itemClassName="border-[color-mix(in_oklab,var(--color-info)_35%,transparent)] bg-[color-mix(in_oklab,var(--color-info)_10%,transparent)] text-info hover:bg-[color-mix(in_oklab,var(--color-info)_20%,transparent)]"
/>
)
}
/* Success: onaylayici yesil ton. */
export function SuccessButtonGroup(props: GroupProps) {
return (
<ToneShell
props={props}
tone="success"
label="Success actions"
icon={<CheckCircle2 />}
itemClassName="border-[color-mix(in_oklab,var(--color-success)_35%,transparent)] bg-[color-mix(in_oklab,var(--color-success)_10%,transparent)] text-success hover:bg-[color-mix(in_oklab,var(--color-success)_20%,transparent)]"
/>
)
}
/* Warning: dikkat cekici amber ton. */
export function WarningButtonGroup(props: GroupProps) {
return (
<ToneShell
props={props}
tone="warning"
label="Warning actions"
icon={<AlertTriangle />}
itemClassName="border-[color-mix(in_oklab,var(--color-warning)_35%,transparent)] bg-[color-mix(in_oklab,var(--color-warning)_10%,transparent)] text-warning hover:bg-[color-mix(in_oklab,var(--color-warning)_20%,transparent)]"
/>
)
}
/* Danger: a red tone for destructive actions. */
export function DangerButtonGroup(props: GroupProps) {
return (
<ToneShell
props={props}
tone="danger"
label="Danger actions"
icon={<Ban />}
itemClassName="border-[color-mix(in_oklab,var(--color-danger)_35%,transparent)] bg-[color-mix(in_oklab,var(--color-danger)_10%,transparent)] text-danger hover:bg-[color-mix(in_oklab,var(--color-danger)_20%,transparent)]"
/>
)
}
/* Muted: a quiet neutral tone, for secondary action rows. */
export function MutedButtonGroup(props: GroupProps) {
return (
<ToneShell
props={props}
tone="neutral"
label="Muted actions"
icon={<Circle />}
itemClassName="border-border bg-[color-mix(in_oklab,var(--color-foreground)_5%,transparent)] text-muted-foreground hover:bg-[color-mix(in_oklab,var(--color-foreground)_10%,transparent)] hover:text-foreground"
/>
)
}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.
Info
An informational tone with a soft tinted fill.
import { InfoButtonGroup } from "@/components/ui/button-group-tone"
<InfoButtonGroup />Success
A confirming tone for positive actions.
import { SuccessButtonGroup } from "@/components/ui/button-group-tone"
<SuccessButtonGroup />Warning
A cautionary tone that asks for a second look.
import { WarningButtonGroup } from "@/components/ui/button-group-tone"
<WarningButtonGroup />Danger
A destructive tone for irreversible actions.
import { DangerButtonGroup } from "@/components/ui/button-group-tone"
<DangerButtonGroup />Muted
A quiet neutral tone for secondary rows.
import { MutedButtonGroup } from "@/components/ui/button-group-tone"
<MutedButtonGroup />ai2 Tone button groups: 5 styled variations on the token system
The ai2 Tone button groups are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around attached action groups colored by semantic tone. 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 Tone button groups?
5 exports in one file: Info, Success, Warning, Danger and Muted. 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 Tone 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.