Primary scroll areas
Five scroll areas with a primary-accent thumb: solid, soft, ring, gradient and glow. Each styles its own WebKit thumb with the primary token family, needs no global stylesheet, and is sized.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/scroll-area-primaryDependencies, the @ai2/tokens theme and the component file are installed together.
Copy the source
components/ui/scroll-area-primary.tsx"use client"
import type * as React from "react"
import { cn } from "@/lib/utils"
/* Scroll-area primary ailesi: 5 dekoratif kaydirma alani. Thumb primary aksan
tonunu tasar (solid, soft, ring, gradient, glow). Renkler YALNIZ token; alfa
color-mix ile. size -> viewport yuksekligi. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const height: Record<StyledSize, string> = {
sm: "h-40",
md: "h-56",
lg: "h-72",
xl: "h-96",
}
const base = "w-full overflow-y-auto rounded-lg border border-border bg-surface-2 p-3"
/* Varsayilan icerik: kaydirmayi tetikleyecek kadar uzun, token-stilli satirlar. */
function DefaultRows({ count = 16 }: { count?: number }) {
return (
<div className="flex flex-col gap-2">
{Array.from({ length: count }).map((_, i) => (
<div
key={i}
className="flex items-center justify-between rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground"
>
<span className="font-medium">Satir {i + 1}</span>
<span className="text-xs text-muted-foreground">token</span>
</div>
))}
</div>
)
}
type Props = {
className?: string
size?: StyledSize
children?: React.ReactNode
}
/* Solid: dolu primary thumb. */
export function SolidPrimaryScrollArea({ className, size = "md", children }: Props) {
return (
<div
data-slot="styled-scroll-area"
className={cn(
base,
height[size],
"[scrollbar-width:thin] [scrollbar-color:var(--color-primary)_transparent]",
"[&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-primary",
className
)}
>
{children ?? <DefaultRows />}
</div>
)
}
/* Soft: yari saydam primary thumb. */
export function SoftPrimaryScrollArea({ className, size = "md", children }: Props) {
return (
<div
data-slot="styled-scroll-area"
className={cn(
base,
height[size],
"[scrollbar-width:thin] [scrollbar-color:color-mix(in_oklab,var(--color-primary)_45%,transparent)_transparent]",
"[&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-[color-mix(in_oklab,var(--color-primary)_45%,transparent)]",
className
)}
>
{children ?? <DefaultRows />}
</div>
)
}
/* Ring: primary cerceveli, ici seyreltilmis thumb (halka gorunumu). */
export function RingPrimaryScrollArea({ className, size = "md", children }: Props) {
return (
<div
data-slot="styled-scroll-area"
className={cn(
base,
height[size],
"[scrollbar-width:thin] [scrollbar-color:var(--color-primary)_transparent]",
"[&::-webkit-scrollbar]:w-3 [&::-webkit-scrollbar-track]:bg-transparent",
"[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:border-2 [&::-webkit-scrollbar-thumb]:border-solid [&::-webkit-scrollbar-thumb]:border-primary [&::-webkit-scrollbar-thumb]:bg-[color-mix(in_oklab,var(--color-primary)_18%,transparent)]",
className
)}
>
{children ?? <DefaultRows />}
</div>
)
}
/* Gradient: a thumb with a vertical gradient from primary to a diluted primary. */
export function GradientPrimaryScrollArea({ className, size = "md", children }: Props) {
return (
<div
data-slot="styled-scroll-area"
className={cn(
base,
height[size],
"[scrollbar-width:thin] [scrollbar-color:var(--color-primary)_transparent]",
"[&::-webkit-scrollbar]:w-2.5 [&::-webkit-scrollbar-track]:bg-transparent",
"[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gradient-to-b [&::-webkit-scrollbar-thumb]:from-primary [&::-webkit-scrollbar-thumb]:to-[color-mix(in_oklab,var(--color-primary)_50%,transparent)]",
className
)}
>
{children ?? <DefaultRows />}
</div>
)
}
/* Glow: primary thumb + primary tonlu isilti golgesi. */
export function GlowPrimaryScrollArea({ className, size = "md", children }: Props) {
return (
<div
data-slot="styled-scroll-area"
className={cn(
base,
height[size],
"[scrollbar-width:thin] [scrollbar-color:var(--color-primary)_transparent]",
"[&::-webkit-scrollbar]:w-2.5 [&::-webkit-scrollbar-track]:bg-transparent",
"[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-primary [&::-webkit-scrollbar-thumb]:shadow-[0_0_8px_color-mix(in_oklab,var(--color-primary)_60%,transparent)]",
className
)}
>
{children ?? <DefaultRows />}
</div>
)
}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.
Solid
A solid primary thumb.
import { SolidPrimaryScrollArea } from "@/components/ui/scroll-area-primary"
<SolidPrimaryScrollArea />Soft
A translucent primary thumb.
import { SoftPrimaryScrollArea } from "@/components/ui/scroll-area-primary"
<SoftPrimaryScrollArea />Ring
A primary-bordered, near-hollow ring thumb.
import { RingPrimaryScrollArea } from "@/components/ui/scroll-area-primary"
<RingPrimaryScrollArea />Gradient
A vertical gradient thumb from primary to a lighter primary.
import { GradientPrimaryScrollArea } from "@/components/ui/scroll-area-primary"
<GradientPrimaryScrollArea />Glow
A primary thumb with a primary-tinted glow shadow.
import { GlowPrimaryScrollArea } from "@/components/ui/scroll-area-primary"
<GlowPrimaryScrollArea />ai2 Primary scroll areas: 5 styled variations on the token system
The ai2 Primary scroll areas are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around scroll containers with a primary-accent scrollbar thumb. 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: the accent thumb styling is pure CSS; 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, nothing animates; the areas still scroll and keep the accent thumb.
What is in the ai2 Primary scroll areas?
5 exports in one file: Solid, Soft, Ring, Gradient 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: the accent thumb styling is pure CSS; no motion library work is required.
- Reduced-motion aware: Under prefers-reduced-motion, nothing animates; the areas still scroll and keep the accent thumb.
- 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 Primary scroll areas 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.