Stroke buttons
Five takes on the border: a rotating arc, a fast beam, a static gradient edge, extending corners and a growing ring. Each is sized 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/buttons-strokeDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install motionCopy the source
components/ui/buttons-stroke.tsx"use client"
import type * as React from "react"
import { motion, useReducedMotion, type HTMLMotionProps } from "motion/react"
import { cn } from "@/lib/utils"
/* Stroke button family: 5 variations on edges and frames. All are sized, use framer-motion, take colour ONLY from semantic tokens and are reduced-motion safe. The rotating rings derive from two layers: the outer one a gradient or conic, the inner one covering the middle with bg. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
/* Ring structure (Rotate/Beam/Gradient): outer height plus inner fill and radius. */
const ring: Record<StyledSize, string> = {
sm: "h-8 rounded-md",
md: "h-9 rounded-lg",
lg: "h-10 rounded-lg",
xl: "h-12 rounded-xl",
}
const ringInner: Record<StyledSize, string> = {
sm: "gap-1.5 rounded-[5px] px-3 text-sm",
md: "gap-2 rounded-[7px] px-4 text-sm",
lg: "gap-2 rounded-[7px] px-5 text-sm",
xl: "gap-2.5 rounded-[11px] px-6 text-base",
}
/* Duz yapi (Corners/Grow). */
const flat: Record<StyledSize, string> = {
sm: "h-8 gap-1.5 rounded-md px-3 text-sm",
md: "h-9 gap-2 rounded-lg px-4 text-sm",
lg: "h-10 gap-2 rounded-lg px-5 text-sm",
xl: "h-12 gap-2.5 rounded-xl px-6 text-base",
}
const ringBase =
"group relative inline-flex shrink-0 select-none items-center justify-center overflow-hidden p-px text-sm font-medium whitespace-nowrap outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50"
const ringInnerBase =
"relative inline-flex h-full w-full items-center justify-center bg-background text-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base"
const flatBase =
"group relative inline-flex shrink-0 select-none items-center justify-center font-medium whitespace-nowrap text-foreground outline-none 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"
type Props = HTMLMotionProps<"button"> & { size?: StyledSize }
/* Rotate: buton cevresinde donen genis konik token yay. */
export function RotateStrokeButton({ className, size = "md", children, ...props }: Props) {
const reduce = useReducedMotion()
return (
<motion.button
data-slot="styled-button"
whileTap={reduce ? undefined : { scale: 0.97 }}
transition={{ type: "spring", stiffness: 400, damping: 20 }}
className={cn(ringBase, ring[size], "bg-border", className)}
{...props}
>
<motion.span
aria-hidden="true"
className="absolute inset-[-150%] motion-reduce:hidden"
style={{ background: "conic-gradient(from 0deg, transparent 0deg, var(--info) 70deg, transparent 140deg)" }}
animate={reduce ? undefined : { rotate: 360 }}
transition={reduce ? undefined : { duration: 4, ease: "linear", repeat: Infinity }}
/>
<span className={cn(ringInnerBase, ringInner[size])}>{children as React.ReactNode}</span>
</motion.button>
)
}
/* Beam: dar ve parlak tek isik yayi kenar boyunca hizli doner. */
export function BeamButton({ className, size = "md", children, ...props }: Props) {
const reduce = useReducedMotion()
return (
<motion.button
data-slot="styled-button"
whileTap={reduce ? undefined : { scale: 0.97 }}
transition={{ type: "spring", stiffness: 400, damping: 20 }}
className={cn(ringBase, ring[size], "bg-border", className)}
{...props}
>
<motion.span
aria-hidden="true"
className="absolute inset-[-150%] motion-reduce:hidden"
style={{ background: "conic-gradient(from 0deg, transparent 0deg, var(--brand) 18deg, color-mix(in_oklab,var(--brand)_50%,transparent) 30deg, transparent 42deg)" }}
animate={reduce ? undefined : { rotate: 360 }}
transition={reduce ? undefined : { duration: 2.4, ease: "linear", repeat: Infinity }}
/>
<span className={cn(ringInnerBase, ringInner[size], "bg-card")}>{children as React.ReactNode}</span>
</motion.button>
)
}
/* Gradient: statik cok tonlu token gradyan kenar. */
export function GradientStrokeButton({ className, size = "md", children, ...props }: Props) {
const reduce = useReducedMotion()
return (
<motion.button
data-slot="styled-button"
whileHover={reduce ? undefined : { scale: 1.03 }}
whileTap={reduce ? undefined : { scale: 0.97 }}
transition={{ type: "spring", stiffness: 400, damping: 20 }}
className={cn(ringBase, ring[size], "[background-image:linear-gradient(120deg,var(--info),var(--brand),var(--success))]", className)}
{...props}
>
<span className={cn(ringInnerBase, ringInner[size])}>{children as React.ReactNode}</span>
</motion.button>
)
}
/* Corners: the four corner brackets extend on hover (token border). */
export function CornersButton({ className, size = "md", children, ...props }: Props) {
const reduce = useReducedMotion()
return (
<motion.button
data-slot="styled-button"
whileTap={reduce ? undefined : { scale: 0.97 }}
transition={{ type: "spring", stiffness: 400, damping: 20 }}
className={cn(flatBase, flat[size], "border border-border/60", className)}
{...props}
>
<span aria-hidden="true" className="pointer-events-none absolute left-0 top-0 h-2 w-2 rounded-tl-md border-l-2 border-t-2 border-primary transition-all duration-(--motion-base) group-hover:h-4 group-hover:w-4" />
<span aria-hidden="true" className="pointer-events-none absolute bottom-0 right-0 h-2 w-2 rounded-br-md border-b-2 border-r-2 border-primary transition-all duration-(--motion-base) group-hover:h-4 group-hover:w-4" />
<span className="relative flex items-center gap-2">{children as React.ReactNode}</span>
</motion.button>
)
}
/* Grow: a token ring growing from zero on hover. */
export function GrowRingButton({ className, size = "md", children, ...props }: Props) {
const reduce = useReducedMotion()
return (
<motion.button
data-slot="styled-button"
whileTap={reduce ? undefined : { scale: 0.97 }}
transition={{ type: "spring", stiffness: 400, damping: 20 }}
className={cn(
flatBase,
flat[size],
"border border-border ring-0 ring-primary/50 ring-offset-2 ring-offset-background transition-[box-shadow] duration-(--motion-base) hover:ring-2",
className
)}
{...props}
>
<span className="relative flex items-center gap-2">{children as React.ReactNode}</span>
</motion.button>
)
}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.
Rotate
A wide conic token arc rotates around the border.
import { RotateStrokeButton } from "@/components/ui/buttons-stroke"
<RotateStrokeButton>Rotate</RotateStrokeButton>Beam
A tight, bright arc travels quickly around the edge.
import { BeamButton } from "@/components/ui/buttons-stroke"
<BeamButton>Beam</BeamButton>Gradient
A static multi-token gradient border.
import { GradientStrokeButton } from "@/components/ui/buttons-stroke"
<GradientStrokeButton>Gradient</GradientStrokeButton>Corners
Two token corner brackets extend on hover.
import { CornersButton } from "@/components/ui/buttons-stroke"
<CornersButton>Corners</CornersButton>Grow
A token ring grows from nothing on hover.
import { GrowRingButton } from "@/components/ui/buttons-stroke"
<GrowRingButton>Grow</GrowRingButton>ai2 Stroke buttons: 5 styled variations on the token system
The ai2 Stroke buttons are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around animated and static borders. 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 rotates the conic arc and the beam; the corners and ring run on token 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 rotation stops and a static token border remains.
What is in the ai2 Stroke buttons?
5 exports in one file: Rotate, Beam, Gradient, Corners and Grow. 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 rotates the conic arc and the beam; the corners and ring run on token transitions.
- Reduced-motion aware: Under prefers-reduced-motion, the rotation stops and a static token border remains.
- 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 Stroke buttons 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.