Tone input groups
Five input groups that share one anatomy and vary only the semantic color: info, success, warning, danger and muted. Each carries a state icon, a hint chip and a real labelled input, and the danger variant uses the ai2 aria-invalid standard.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/input-group-toneDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install lucide-reactCopy the source
components/ui/input-group-tone.tsx"use client"
import * as React from "react"
import { AlertTriangle, CheckCircle2, CircleSlash, Info, OctagonAlert } from "lucide-react"
import { cn } from "@/lib/utils"
/* Tone input group family: 5 semantically toned fields. The anatomy is the same (a state icon plus a real <input> plus a helper-text chip), and the difference is ONLY the semantic colour: info, success, warning, danger, muted. Every root carries data-tone. The danger variant uses the ai2 standard aria-invalid appearance (NOT destructive). Colour comes ONLY from tokens; alpha via color-mix. No motion. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const height: Record<StyledSize, string> = {
sm: "h-8 text-sm",
md: "h-9 text-sm",
lg: "h-10 text-base",
xl: "h-12 text-base",
}
const rootBase =
"group inline-flex w-64 max-w-full items-center overflow-hidden rounded-lg border bg-transparent transition-colors duration-(--motion-base) focus-within:ring-[3px] [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none"
const fieldBase =
"h-full w-full min-w-0 bg-transparent px-2 text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50"
type Props = Omit<React.ComponentProps<"input">, "size"> & { size?: StyledSize }
/* Shared shell: toneClassName carries the border, ring and ground tone, the icon carries the state. */
function ToneShell({
className,
size = "md",
tone,
toneClassName,
iconClassName,
icon,
label,
hint,
invalid,
...props
}: Props & {
tone: string
toneClassName: string
iconClassName: string
icon: React.ReactNode
label: string
hint: string
invalid?: boolean
}) {
const id = React.useId()
return (
<div
data-slot="styled-input-group"
data-tone={tone}
className={cn(rootBase, height[size], toneClassName, className)}
>
<label htmlFor={id} className="sr-only">
{label}
</label>
<span className={cn("ml-3 shrink-0", iconClassName)}>{icon}</span>
<input
id={id}
aria-invalid={invalid ? true : undefined}
{...props}
className={fieldBase}
/>
<span className="mr-3 shrink-0 select-none text-xs text-muted-foreground">{hint}</span>
</div>
)
}
/* Info: an informational tone, an info edge over a neutral field. */
export function InfoGroup(props: Props) {
return (
<ToneShell
{...props}
tone="info"
label="Info field"
hint="Info"
icon={<Info />}
iconClassName="text-info"
toneClassName="border-info bg-[color-mix(in_oklab,var(--color-info)_6%,transparent)] focus-within:border-info focus-within:ring-info/20 dark:focus-within:ring-info/40"
/>
)
}
/* Success: dogrulanmis alan gorunumu. */
export function SuccessGroup(props: Props) {
return (
<ToneShell
{...props}
tone="success"
label="Success field"
hint="Valid"
icon={<CheckCircle2 />}
iconClassName="text-success"
toneClassName="border-success bg-[color-mix(in_oklab,var(--color-success)_6%,transparent)] focus-within:border-success focus-within:ring-success/20 dark:focus-within:ring-success/40"
/>
)
}
/* Warning: dikkat isteyen ama bloklamayan alan. */
export function WarningGroup(props: Props) {
return (
<ToneShell
{...props}
tone="warning"
label="Warning field"
hint="Check"
icon={<AlertTriangle />}
iconClassName="text-warning"
toneClassName="border-warning bg-[color-mix(in_oklab,var(--color-warning)_6%,transparent)] focus-within:border-warning focus-within:ring-warning/20 dark:focus-within:ring-warning/40"
/>
)
}
/* Danger: the ai2 invalid standard (danger tokens, not destructive). */
export function DangerGroup(props: Props) {
return (
<ToneShell
{...props}
tone="danger"
label="Danger field"
hint="Error"
invalid
icon={<OctagonAlert />}
iconClassName="text-danger"
toneClassName="border-danger bg-[color-mix(in_oklab,var(--color-danger)_6%,transparent)] focus-within:border-danger focus-within:ring-danger/20 dark:focus-within:ring-danger/40 has-[[aria-invalid=true]]:border-danger has-[[aria-invalid=true]]:ring-danger/20 dark:has-[[aria-invalid=true]]:ring-danger/40"
/>
)
}
/* Muted: sessiz/pasif ton, dikkat cekmeyen alan. */
export function MutedGroup(props: Props) {
return (
<ToneShell
{...props}
tone="neutral"
label="Muted field"
hint="Optional"
icon={<CircleSlash />}
iconClassName="text-muted-foreground"
toneClassName="border-field-border bg-surface-2 focus-within:border-primary focus-within:ring-ring/50"
/>
)
}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 an info border and icon.
import { InfoGroup } from "@/components/ui/input-group-tone"
<InfoGroup placeholder="Value" />Success
A validated field with the success tone.
import { SuccessGroup } from "@/components/ui/input-group-tone"
<SuccessGroup placeholder="Value" />Warning
A field that needs attention without blocking.
import { WarningGroup } from "@/components/ui/input-group-tone"
<WarningGroup placeholder="Value" />Danger
The ai2 invalid look driven by danger tokens.
import { DangerGroup } from "@/components/ui/input-group-tone"
<DangerGroup placeholder="Value" />Muted
A quiet optional field that stays in the background.
import { MutedGroup } from "@/components/ui/input-group-tone"
<MutedGroup placeholder="Value" />ai2 Tone input groups: 5 styled variations on the token system
The ai2 Tone input groups are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around inputs tinted by a semantic tone with a state icon. 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: focus-within highlights run on token 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, the transitions are disabled and the field still focuses.
What is in the ai2 Tone input 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: focus-within highlights run on token CSS transitions.
- Reduced-motion aware: Under prefers-reduced-motion, the transitions are disabled and the field still focuses.
- 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 input 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.