Tone labels
Five labels that carry a semantic tone: info, success, warning, danger and muted. Each root exposes data-tone, colors resolve to ai2 tokens only, and every label is a real label element bound to its input with htmlFor.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/label-toneDependencies, the @ai2/tokens theme and the component file are installed together.
Copy the source
components/ui/label-tone.tsx"use client"
import * as React from "react"
import { cn } from "@/lib/utils"
/* Tone label family: 5 semantically toned form labels (info, success, warning,
danger, muted). This is a SEPARATE styled component; the base label does not
change. Every root carries data-tone. The label is a REAL <label> bound with
htmlFor to the rendered demo input (the id is produced by React.useId()) - an
unbound label is an a11y bug. The tone dot uses currentColor, so it inherits the
tone color. Color comes ONLY from tokens. Static - no animation, motion is not
needed. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const text: Record<StyledSize, string> = {
sm: "text-xs",
md: "text-sm",
lg: "text-sm",
xl: "text-base",
}
/* Demo input yuksekligi base Button olcegine hizali. */
const inputHeight: Record<StyledSize, string> = {
sm: "h-8",
md: "h-9",
lg: "h-10",
xl: "h-12",
}
const base =
"inline-flex w-fit items-center gap-1.5 font-medium leading-none select-none [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none"
const field = "flex w-fit flex-col gap-1.5"
const inputBase =
"w-48 rounded-md border border-field-border bg-transparent px-3 text-sm text-foreground outline-none transition-colors placeholder:text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50"
type Props = Omit<React.ComponentProps<"label">, "htmlFor"> & { size?: StyledSize }
/* Shared shell: the tone colour goes on the label and the tone dot rides the same colour through currentColor. The root carries data-slot plus data-tone; the label is bound to the demo input with htmlFor. */
function ToneField({
tone,
toneClass,
className,
size = "md",
children,
...props
}: Props & { tone: string; toneClass: string }) {
const id = React.useId()
return (
<span data-slot="styled-label" data-tone={tone} className={field}>
<label
htmlFor={id}
className={cn(base, text[size], toneClass, className)}
{...props}
>
<span
aria-hidden="true"
className="size-1.5 shrink-0 rounded-full [background-color:currentColor]"
/>
{children ?? "Email"}
</label>
<input
id={id}
type="text"
placeholder="you@example.com"
className={cn(inputBase, inputHeight[size])}
/>
</span>
)
}
/* Info: bilgilendirici ton. */
export function InfoLabel(props: Props) {
return <ToneField tone="info" toneClass="text-info" {...props} />
}
/* Success: olumlu/dogrulanmis ton. */
export function SuccessLabel(props: Props) {
return <ToneField tone="success" toneClass="text-success" {...props} />
}
/* Warning: dikkat isteyen ton. */
export function WarningLabel(props: Props) {
return <ToneField tone="warning" toneClass="text-warning" {...props} />
}
/* Danger: hata/yikici ton. */
export function DangerLabel(props: Props) {
return <ToneField tone="danger" toneClass="text-danger" {...props} />
}
/* Muted: ikincil, geri cekilmis ton. */
export function MutedLabel(props: Props) {
return <ToneField tone="muted" toneClass="text-muted-foreground" {...props} />
}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 for a neutral, explanatory field.
import { InfoLabel } from "@/components/ui/label-tone"
<InfoLabel>Email</InfoLabel>Success
A positive tone for a verified or confirmed field.
import { SuccessLabel } from "@/components/ui/label-tone"
<SuccessLabel>Email</SuccessLabel>Warning
A cautionary tone for a field that needs attention.
import { WarningLabel } from "@/components/ui/label-tone"
<WarningLabel>Email</WarningLabel>Danger
A destructive tone for an invalid or risky field.
import { DangerLabel } from "@/components/ui/label-tone"
<DangerLabel>Email</DangerLabel>Muted
A quiet tone for a secondary field that should recede.
import { MutedLabel } from "@/components/ui/label-tone"
<MutedLabel>Email</MutedLabel>ai2 Tone labels: 5 styled variations on the token system
The ai2 Tone labels are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around semantic tone applied to a form label. 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: these labels are static, so no motion library work is required. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, there is no motion to reduce.
What is in the ai2 Tone labels?
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: these labels are static, so no motion library work is required.
- Reduced-motion aware: Under prefers-reduced-motion, there is no motion to reduce.
- 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 labels 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.