Styled separator
Five divider treatments: a fading gradient, a dashed line, a labeled break, an icon break and a glowing line. Each is sized by thickness and token-driven.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/separator-styledDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install motion lucide-reactCopy the source
components/ui/separator-styled.tsx"use client"
import type * as React from "react"
import { motion, useReducedMotion } from "motion/react"
import { Asterisk } from "lucide-react"
import { cn } from "@/lib/utils"
/* Separator family: 5 decorative horizontal separators. Colour comes ONLY from tokens (alpha via color-mix), and size controls the thickness (sm..xl). framer-motion is used only for the Dashed march; it stops under reduced-motion. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const thickness: Record<StyledSize, string> = {
sm: "h-px",
md: "h-0.5",
lg: "h-1",
xl: "h-1.5",
}
const labelText: Record<StyledSize, string> = {
sm: "text-xs",
md: "text-xs",
lg: "text-sm",
xl: "text-sm",
}
type Props = React.ComponentProps<"div"> & { size?: StyledSize }
/* Gradient: a token line fading to transparent at both ends. */
export function GradientSeparator({ className, size = "md", ...props }: Props) {
return (
<div
data-slot="styled-separator"
role="separator"
aria-orientation="horizontal"
className={cn(
"w-full bg-gradient-to-r from-transparent via-border to-transparent",
thickness[size],
className
)}
{...props}
/>
)
}
/* Dashed: a dashed token line; a slow march outside reduced-motion. */
export function DashedSeparator({ className, size = "md", ...props }: Props) {
const reduce = useReducedMotion()
return (
<div
data-slot="styled-separator"
role="separator"
aria-orientation="horizontal"
className={cn("w-full overflow-hidden", thickness[size], className)}
{...props}
>
{reduce ? (
<div className="size-full [background-image:repeating-linear-gradient(90deg,var(--color-border)_0,var(--color-border)_8px,transparent_8px,transparent_14px)]" />
) : (
<motion.div
className="h-full w-[calc(100%+14px)] [background-image:repeating-linear-gradient(90deg,var(--color-border)_0,var(--color-border)_8px,transparent_8px,transparent_14px)]"
animate={{ x: [0, -14] }}
transition={{ duration: 1.2, ease: "linear", repeat: Infinity }}
/>
)}
</div>
)
}
/* Label: a line with a label inside a token chip in the middle. */
export function LabelSeparator({ className, size = "md", children, ...props }: Props) {
return (
<div
data-slot="styled-separator"
role="separator"
aria-orientation="horizontal"
className={cn("flex w-full items-center gap-3", className)}
{...props}
>
<span className={cn("flex-1 bg-border", thickness[size])} />
<span
className={cn(
"shrink-0 rounded-full border border-border bg-secondary px-2.5 py-0.5 font-medium text-secondary-foreground",
labelText[size]
)}
>
{children}
</span>
<span className={cn("flex-1 bg-border", thickness[size])} />
</div>
)
}
/* Icon: a line with a token icon in the middle (an asterisk by default). */
export function IconSeparator({
className,
size = "md",
icon,
...props
}: Props & { icon?: React.ReactNode }) {
return (
<div
data-slot="styled-separator"
role="separator"
aria-orientation="horizontal"
className={cn(
"flex w-full items-center gap-3 text-muted-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none",
labelText[size],
className
)}
{...props}
>
<span className={cn("flex-1 bg-border", thickness[size])} />
<span className="inline-flex shrink-0 items-center justify-center">
{icon ?? <Asterisk />}
</span>
<span className={cn("flex-1 bg-border", thickness[size])} />
</div>
)
}
/* Glow: a token line with a soft glow shadow. */
export function GlowSeparator({ className, size = "md", ...props }: Props) {
return (
<div
data-slot="styled-separator"
role="separator"
aria-orientation="horizontal"
className={cn(
"w-full bg-border shadow-[0_0_10px_-1px_var(--color-border)]",
thickness[size],
className
)}
{...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.
Gradient
A token line that fades out at both ends.
import { GradientSeparator } from "@/components/ui/separator-styled"
<GradientSeparator />Dashed
A dashed token line, optionally marching.
import { DashedSeparator } from "@/components/ui/separator-styled"
<DashedSeparator />Label
A line broken by a centered label chip.
import { LabelSeparator } from "@/components/ui/separator-styled"
<LabelSeparator>Section</LabelSeparator>Icon
A line broken by a centered token icon.
import { IconSeparator } from "@/components/ui/separator-styled"
<IconSeparator />Glow
A token line with a soft glow.
import { GlowSeparator } from "@/components/ui/separator-styled"
<GlowSeparator />ai2 Styled separator: 5 styled variations on the token system
The ai2 Styled separator are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around decorative dividers. 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: framer-motion marches the dashed line; the rest are static. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, the marching stops and the dividers stay still.
What is in the ai2 Styled separator?
5 exports in one file: Gradient, Dashed, Label, Icon and Glow. 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: framer-motion marches the dashed line; the rest are static.
- Reduced-motion aware: Under prefers-reduced-motion, the marching stops and the dividers stay still.
- 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 Styled separator 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.