A connected activity feed with flexible event content, timestamps, and cards.
Default
Project activity
A little momentum, one update at a time.
Alex moved the project to
Ready to ship Ready to shipDesign handoff is ready
Updated flows, interaction notes, and assets are in the shared workspace.
Open handoff notesSam approved the final review
Jordan joined the workspace
Horizontal
Order received
Packed
Shipped
Feed
Design approved
Review completed
Delivery
On its way
Shipment ST–2048 · Expected today
Out for delivery
Your parcel is with your local courier.
Arrived at the local depot
Northside distribution center
Collected from the sender
Tracking updates are now available.
Shipping label created
The sender prepared your order.
Branch
Release journal
Related updates stay together, without crowding the feed.
Version 2.4 is live
Release notes sent to the team
Everything you need for a smooth handoff, in one place.
Show 2 related updatesHide related updates
Migration guide updated
Includes examples for existing projects.
Accessibility review completed
Sam joined the release team
Community walkthrough
Scheduled · Bring your questions and ideas.
Loading
Activity
Loading the latest updates…
Empty
Workspace activity
Your team's story starts here.
Nothing to catch up on
New comments, shared files, and project updates will appear here.
Retry
Recent activity
Keep errors local to the feed.
We couldn't load your activity
Your existing work is safe. Give the feed another try.
Marker Styles
A quieter rhythm
Choose a rail and marker treatment to suit the information.
Soft markers · Solid rail
Outline markers · Dashed and solid rails
Plain markers · Solid rail
Versions
Version history
The milestones and small improvements along the way.
Added two new lessons
New lesson images, quizzes, and a refreshed course survey
Updated the illustrations in lesson two
Refined quiz questions and answer explanations
Improved the lesson ten walkthrough
Updated the introduction examples
Activity Filter
Northstar activity
Meetings, shared files, and the conversations between them.
Showing all activity.
Upcoming
Northstar × Studio — project check-in
Review the handoff and agree on the next milestone.
Show 2 more upcoming activitiesHide upcoming activities
Customer onboarding walkthrough
Success team introduction
This week
Alex Morgan added a file to the workspace
Sam Rivera added Northstar to Customer success
Casey Chen left a handoff note
The handoff is approved. Let's introduce the customer success team and keep the momentum going.
Purpose
A timeline shows how events unfold in order, with room for dates, status, and related updates.
Parts & Composition
Use Timeline to group events in order, with a marker and content for each item. For a card with its own heading or actions, place the timeline inside TimelineSurface and TimelineBody alongside the header and footer.
API & Props
| Part | Purpose |
|---|---|
Timeline | Root (orientation, loop, feed, busy, controller, connectorStyle: solid | dashed). |
TimelineSurface, TimelineHeader, TimelineBody, TimelineFooter | Card surface (size: xs | sm | md | lg) and inset regions (separator default false on header, true on footer). |
TimelineItem, TimelineConnector, TimelineMarker | Event row (status: complete | current | upcoming, variant: inline | card), rail segment, and marker (variant: soft | outline | plain). |
TimelineContent, TimelineTitle, TimelineDescription, TimelineTime | Event body, heading, supporting text, and tabular-nums timestamp. |
TimelineBranch, TimelineBranchTrigger | Native <details> disclosure for nested child events. |
See the UI SDK Timeline reference for upstream options on SDK parts. Wrapper-specific props are listed above.
Common props in detail
| Prop | Purpose |
|---|---|
orientation / loop | Configure navigation direction and whether focus wraps. |
feed / busy | Enable feed behavior where appropriate and report when more items are loading. |
connectorStyle | Set the default rail style. Individual connectors can override it through their style prop. |
Theming, Layout & Responsiveness
The surface uses Card’s padding scale. The shared inset tokens derive region padding from --surface-padding at xs (1.3rem), sm (1.35rem), md (1.5rem), and lg (1.75rem).
TimelineSurface uses bg-card, border-border, rounded-lg, and shadow-sm. TimelineMarker (soft) and TimelineContent (variant="card") use bg-popover, border-border, shadow-sm, and hover:shadow-md on interactive cards. TimelineHeader defaults to separator={false} and TimelineFooter defaults to separator={true}.
TimelineSurface size (xs | sm | md | lg) scales --surface-padding, surfaceRegionInset, and surfaceBodyPadding inside TimelineBody. Horizontal timelines scroll smoothly with overscroll-x-contain.
Motion & Accessibility
TimelineBranch uses native <details> interpolate-size: allow-keywords height/opacity/blur transitions (200ms), disabled under prefers-reduced-motion.
UI SDK manages roving focus and sets aria-current="step" on the current event. Use Up/Down in vertical lists, Left/Right in horizontal lists, and Page Up/Page Down in feed mode.
Guidance for Coding Agents
Compose event items with stable values and meaningful titles, times, and status text. Use TimelineBody for the inset surface and the built-in connector parts for rails. Let the app own data order, pagination, and any related event disclosures.
Always wrap Timeline content inside TimelineBody when using TimelineSurface.
Start from the closest Preview → Usage example and use this page’s API table for component parts and options. For inherited props, callbacks, keyboard behavior, and rendering options, consult UI SDK Timeline.
CLI installation
bunx --bun shadcn@latest add https://ui.devvarena.com/api/r/timeline'use client';
import {
Timeline as SDKTimeline,
TimelineConnector as SDKTimelineConnector,
TimelineDescription as SDKTimelineDescription,
TimelineItem as SDKTimelineItem,
TimelineMarker as SDKTimelineMarker,
TimelineTime as SDKTimelineTime,
TimelineTitle as SDKTimelineTitle,
} from '@ui-sdk/react/timeline';
import { cva } from 'class-variance-authority';
import { ChevronDown } from 'lucide-react';
import type { ComponentProps } from 'react';
import { Button } from '@/components/devvarena-ui/button';
import { Separator } from '@/components/devvarena-ui/separator';
import {
focusRing,
partClass,
type StandardControlSize,
surfaceBodyPadding,
surfaceFooterRadius,
surfaceHeaderRadius,
surfacePadding,
surfaceRegionInset,
} from '@/lib/devvarena-ui';
import { cn } from '@/lib/utils';
const timelineSurfaceSizes = cva(
'flex min-w-0 w-full flex-col gap-2 rounded-lg border border-border bg-card text-card-foreground shadow-sm [--timeline-marker:2rem] [--timeline-gap:0.75rem] [--timeline-row-gap:1.5rem] [--timeline-icon:1rem] [--timeline-text:0.875rem] [--timeline-card-padding:0.75rem] md:[--timeline-card-padding:1rem]',
{
variants: {
size: {
xs: '[--surface-padding:1.3rem]',
sm: '[--surface-padding:1.35rem]',
md: '',
lg: '[--surface-padding:1.75rem]',
} satisfies Record<StandardControlSize, string>,
},
defaultVariants: { size: 'md' },
},
);
type TimelineSurfaceProps = ComponentProps<'section'> & {
size?: StandardControlSize;
};
/** A display surface; event data, grouping, fetching and actions stay consumer-owned. */
function TimelineSurface({ className, size = 'md', ...props }: TimelineSurfaceProps) {
return (
<section
{...props}
data-slot="timeline-surface"
data-size={size}
className={cn(surfacePadding, timelineSurfaceSizes({ size }), className)}
/>
);
}
function TimelineHeader({
separator = false,
className,
children,
...props
}: ComponentProps<'header'> & { separator?: boolean }) {
return (
<header
{...props}
data-slot="timeline-surface-header"
className={cn(
'relative flex min-w-0 flex-wrap items-start justify-between gap-3',
surfaceHeaderRadius,
surfaceRegionInset,
className,
)}
>
{separator ? <Separator className="absolute inset-x-0 bottom-0 w-auto" /> : null}
{children}
</header>
);
}
function TimelineSurfaceTitle({ className, ...props }: ComponentProps<'h2'>) {
return (
<h2
{...props}
data-slot="timeline-surface-title"
className={cn('flex items-center gap-2 text-xl font-semibold tracking-tight', className)}
/>
);
}
function TimelineSurfaceDescription({ className, ...props }: ComponentProps<'p'>) {
return (
<p
{...props}
data-slot="timeline-surface-description"
className={cn('mt-1 text-sm leading-relaxed text-muted-foreground', className)}
/>
);
}
type TimelineProps = ComponentProps<typeof SDKTimeline> & {
connectorStyle?: 'solid' | 'dashed';
};
function Timeline({ className, connectorStyle = 'solid', ...props }: TimelineProps) {
return (
<SDKTimeline
{...props}
data-connector={connectorStyle}
className={partClass(
cn(
'm-0 min-w-0 p-0 data-[orientation=horizontal]:flex data-[orientation=horizontal]:overflow-x-auto data-[orientation=horizontal]:overscroll-x-contain data-[orientation=horizontal]:scroll-fade-x',
connectorStyle === 'dashed'
? '[--timeline-connector-style:dashed]'
: '[--timeline-connector-style:solid]',
),
className,
)}
/>
);
}
type TimelineItemProps = ComponentProps<typeof SDKTimelineItem> & {
variant?: 'inline' | 'card';
};
function TimelineItem({ className, variant = 'inline', ...props }: TimelineItemProps) {
return (
<SDKTimelineItem
{...props}
data-variant={variant}
className={partClass(
'group/timeline-item relative grid [&>:is([data-slot=timeline-title],[data-slot=timeline-time],[data-slot=timeline-description])]:col-start-2 data-[orientation=horizontal]:[&>:is([data-slot=timeline-title],[data-slot=timeline-time],[data-slot=timeline-description])]:col-start-1 min-w-0 grid-cols-[var(--timeline-marker,2rem)_minmax(0,1fr)] items-start gap-x-[var(--timeline-gap,0.75rem)] rounded-lg pb-[var(--timeline-row-gap,1.5rem)] outline-none last:pb-0 data-[orientation=horizontal]:min-w-36 data-[orientation=horizontal]:has-[>[data-slot=timeline-branch]]:min-w-60 data-[orientation=horizontal]:flex-[1_0_auto] data-[orientation=horizontal]:grid-cols-[minmax(0,1fr)] data-[orientation=horizontal]:grid-rows-[var(--timeline-marker,2rem)_auto] data-[orientation=horizontal]:gap-y-2 data-[orientation=horizontal]:pb-0 data-[orientation=horizontal]:pe-3',
className,
)}
/>
);
}
function TimelineConnector({ className, ...props }: ComponentProps<typeof SDKTimelineConnector>) {
return (
<SDKTimelineConnector
{...props}
className={partClass(
'pointer-events-none absolute start-[calc(var(--timeline-marker,2rem)/2)] top-[calc(var(--timeline-marker,2rem)+0.25rem)] bottom-1 w-1 -translate-x-[0.5px] rtl:translate-x-[0.5px] border-s border-border [border-style:var(--timeline-connector-style,solid)] [:is(:last-child,[data-last])>&]:hidden [:is(:last-child,[data-last]):not([data-orientation=horizontal]):has(>[data-slot=timeline-branch])>&]:block [:is(:last-child,[data-last]):not([data-orientation=horizontal]):has(>[data-slot=timeline-branch])>&]:static [:is(:last-child,[data-last]):not([data-orientation=horizontal]):has(>[data-slot=timeline-branch])>&]:[grid-area:1/1] [:is(:last-child,[data-last]):not([data-orientation=horizontal]):has(>[data-slot=timeline-branch])>&]:[place-self:stretch_center] [:is(:last-child,[data-last]):not([data-orientation=horizontal]):has(>[data-slot=timeline-branch])>&]:translate-x-[1.5px] rtl:[:is(:last-child,[data-last]):not([data-orientation=horizontal]):has(>[data-slot=timeline-branch])>&]:translate-x-[-1.5px] [:is(:last-child,[data-last]):not([data-orientation=horizontal]):has(>[data-slot=timeline-branch])>&]:[margin-block:calc(var(--timeline-marker,2rem)+0.25rem)_-0.75rem] data-[orientation=horizontal]:start-[calc(var(--timeline-marker,2rem)+0.25rem)] data-[orientation=horizontal]:end-1 data-[orientation=horizontal]:top-[calc(var(--timeline-marker,2rem)/2)] data-[orientation=horizontal]:bottom-auto data-[orientation=horizontal]:h-1 data-[orientation=horizontal]:w-auto data-[orientation=horizontal]:translate-x-0 data-[orientation=horizontal]:border-s-0 data-[orientation=horizontal]:border-t data-[orientation=horizontal]:[border-top-style:var(--timeline-connector-style,solid)]',
className,
)}
/>
);
}
const markerVariants = {
soft: 'border-border bg-popover shadow-sm data-current:border-primary/30 data-current:bg-primary/10 data-upcoming:bg-muted/60',
outline: 'border-border bg-transparent data-current:border-primary/40',
plain: 'border-transparent bg-transparent',
} as const;
type TimelineMarkerProps = ComponentProps<typeof SDKTimelineMarker> & {
variant?: keyof typeof markerVariants;
};
/** Decorative marker. Put meaningful status text in Content as well as an icon/color. */
function TimelineMarker({ className, variant = 'soft', children, ...props }: TimelineMarkerProps) {
return (
<SDKTimelineMarker
{...props}
data-variant={variant}
className={partClass(
cn(
'relative z-10 col-start-1 row-start-1 inline-flex size-[var(--timeline-marker,2rem)] shrink-0 items-center justify-center rounded-lg border text-muted-foreground transition-colors duration-200 data-current:text-primary data-complete:text-foreground [&_svg]:size-[var(--timeline-icon,1rem)] motion-reduce:transition-none',
markerVariants[variant],
),
className,
)}
>
{children ?? <span className="size-1.5 rounded-full bg-current" />}
</SDKTimelineMarker>
);
}
function TimelineContent({ className, ...props }: ComponentProps<'div'>) {
return (
<div
{...props}
data-slot="timeline-content"
className={cn(
'col-start-2 [[data-orientation=horizontal]>&]:col-start-1 [[data-orientation=horizontal]>&]:row-start-2 min-w-0 min-h-[var(--timeline-marker,2rem)] py-1 [overflow-wrap:anywhere] text-[length:var(--timeline-text,0.875rem)] leading-relaxed [[data-variant=card]>&]:rounded-lg [[data-variant=card]>&]:border [[data-variant=card]>&]:border-border [[data-variant=card]>&]:bg-popover [[data-variant=card]>&]:p-[var(--timeline-card-padding,1rem)] [[data-variant=card]>&]:shadow-sm transition-[border-color,box-shadow] duration-200 [[data-variant=card]>&]:has-[a[href],button:not(:disabled),summary]:hover:border-foreground/20 [[data-variant=card]>&]:has-[a[href],button:not(:disabled),summary]:hover:shadow-md [[data-variant=card]>&]:has-[:focus-visible]:border-ring/30 [[data-variant=card]>&]:has-[:focus-visible]:ring-3 [[data-variant=card]>&]:has-[:focus-visible]:ring-ring/15 motion-reduce:transition-none',
className,
)}
/>
);
}
function TimelineTitle({
className,
render = (props) => <h3 {...props}>{props.children}</h3>,
...props
}: ComponentProps<typeof SDKTimelineTitle>) {
return (
<SDKTimelineTitle
{...props}
render={render}
className={partClass(
'text-[length:var(--timeline-text,0.875rem)] font-medium leading-relaxed',
className,
)}
/>
);
}
function TimelineTime({ className, ...props }: ComponentProps<typeof SDKTimelineTime>) {
return (
<SDKTimelineTime
{...props}
className={partClass('text-xs leading-relaxed tabular-nums text-muted-foreground', className)}
/>
);
}
function TimelineDescription({
className,
...props
}: ComponentProps<typeof SDKTimelineDescription>) {
return (
<SDKTimelineDescription
{...props}
className={partClass('text-sm leading-relaxed text-muted-foreground', className)}
/>
);
}
function TimelineBody({ className, ...props }: ComponentProps<'div'>) {
return (
<div
{...props}
data-slot="timeline-surface-body"
className={cn(surfaceRegionInset, surfaceBodyPadding, 'min-w-0', className)}
/>
);
}
function TimelineFooter({
separator = true,
className,
children,
...props
}: ComponentProps<'footer'> & { separator?: boolean }) {
return (
<footer
{...props}
data-slot="timeline-surface-footer"
className={cn(
'relative flex flex-wrap items-center justify-between gap-3 text-xs leading-relaxed text-muted-foreground',
surfaceFooterRadius,
surfaceRegionInset,
className,
)}
>
{separator ? <Separator className="absolute inset-x-0 top-0 w-auto" /> : null}
{children}
</footer>
);
}
/** Related events belong inside the parent Item, after its Content. */
function TimelineBranch({ className, ...props }: ComponentProps<'details'>) {
return (
<details
{...props}
data-slot="timeline-branch"
className={cn(
'group/timeline-branch relative col-start-2 min-w-0 mt-3 [[data-orientation=horizontal]>&]:col-start-1 [[data-orientation=horizontal]>&]:before:hidden before:pointer-events-none before:absolute before:start-[calc(-0.5px-var(--timeline-marker,2rem)/2-var(--timeline-gap,0.75rem))] before:top-0 before:h-[1.375rem] before:w-[calc(var(--timeline-marker,2rem)/2+var(--timeline-gap,0.75rem)+0.5px)] before:rounded-es-lg before:border-s before:border-b before:border-border before:[border-style:var(--timeline-connector-style,solid)] [interpolate-size:allow-keywords] [&::details-content]:h-0 [&::details-content]:overflow-hidden [&::details-content]:opacity-0 [&::details-content]:blur-[3px] [&::details-content]:transition-[height,opacity,filter,content-visibility] [&::details-content]:transition-discrete [&::details-content]:duration-200 open:[&::details-content]:h-auto open:[&::details-content]:opacity-100 open:[&::details-content]:blur-none motion-reduce:[&::details-content]:transition-none',
className,
)}
/>
);
}
function TimelineBranchTrigger({ className, children, ...props }: ComponentProps<'summary'>) {
return (
<summary
{...props}
data-slot="timeline-branch-trigger"
className={cn(
'flex min-h-9 cursor-pointer list-none items-start gap-2 py-2.5 rounded-lg text-[length:var(--timeline-text,0.875rem)] font-medium text-primary hover:text-primary/80 [&::-webkit-details-marker]:hidden',
focusRing,
className,
)}
>
<Button
size="icon-xs"
variant="outline"
aria-label={typeof children === 'string' ? children : 'Toggle branch'}
onClick={(e) => {
e.preventDefault();
const details = e.currentTarget.closest('details');
if (details) details.open = !details.open;
}}
className="shrink-0"
>
<ChevronDown className="transition-transform duration-200 group-open/timeline-branch:rotate-180 motion-reduce:transition-none" />
</Button>
<span className="min-w-0 [overflow-wrap:anywhere] leading-6">{children}</span>
</summary>
);
}
export type { TimelineOptions } from '@ui-sdk/core/timeline';
export type {
TimelineController,
TimelineOrientation,
TimelineStatus,
} from '@ui-sdk/react/timeline';
export { createTimelineController } from '@ui-sdk/react/timeline';
export {
Timeline,
TimelineBody,
TimelineBranch,
TimelineBranchTrigger,
TimelineConnector,
TimelineContent,
TimelineDescription,
TimelineFooter,
TimelineHeader,
TimelineItem,
TimelineMarker,
TimelineSurface,
TimelineSurfaceDescription,
TimelineSurfaceTitle,
TimelineTime,
TimelineTitle,
};
import type { ButtonOptions } from '@ui-sdk/core/button';
import { Button as ButtonPrimitive } from '@ui-sdk/react/button';
import { cva, type VariantProps } from 'class-variance-authority';
import { Loader2 } from 'lucide-react';
import type { ComponentProps, ReactNode } from 'react';
import { controlHeights, controlTextSizes, focusRing } from '@/lib/devvarena-ui';
import { cn } from '@/lib/utils';
/*
* Clean tactile button surfaces with a subtle top highlight, contact shadow,
* and 2% press scale using pure Tailwind/theme tokens.
*/
const flatPress = 'motion-safe:not-data-disabled:not-data-pending:active:scale-[0.985]';
const activeInsetShadow =
'active:shadow-[inset_0_1px_3px_rgb(0_0_0/0.12),0_1px_2px_rgb(0_0_0/0.06)] dark:active:shadow-[inset_0_1px_3px_rgb(0_0_0/0.18),0_1px_2px_rgb(0_0_0/0.1)]';
const tactileFilled =
'bg-[linear-gradient(180deg,rgb(255_255_255/0.16),rgb(255_255_255/0)_75%)] shadow-[inset_0_1.5px_0_rgb(255_255_255/0.22),inset_0_-1px_0_rgb(0_0_0/0.12),0_1px_3px_0_rgb(0_0_0/0.1),0_1px_2px_-1px_rgb(0_0_0/0.1)] active:shadow-[inset_0_1px_3px_rgb(0_0_0/0.18),0_1px_2px_rgb(0_0_0/0.1)]';
const tactileNeutral = `bg-[linear-gradient(180deg,rgb(255_255_255/0.35),transparent_48%,rgb(0_0_0/0.025)_100%)] shadow-[inset_0_1px_0_rgb(255_255_255/0.65),inset_0_-1px_0_rgb(0_0_0/0.06),0_1px_3px_0_rgb(0_0_0/0.1),0_1px_2px_-1px_rgb(0_0_0/0.1)] dark:bg-[linear-gradient(180deg,rgb(255_255_255/0.06),transparent_48%,rgb(0_0_0/0.12)_100%)] dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.1),inset_0_-1px_0_rgb(0_0_0/0.12),0_1px_3px_0_rgb(0_0_0/0.1),0_1px_2px_-1px_rgb(0_0_0/0.1)] ${activeInsetShadow}`;
/** Surface map for button variants, shared with Toggle, Tabs, Radio, Checkbox, and Switch. */
const buttonSurfaces = {
primary: `border-[color-mix(in_oklch,var(--primary),black_8%)] bg-primary text-primary-foreground ${tactileFilled} ${flatPress}`,
secondary: ` bg-popover text-popover-foreground border-[color-mix(in_oklch,var(--muted),black_5%)] ${tactileNeutral} ${flatPress}`,
outline: `border-input bg-accent/10 text-foreground shadow-sm hover:text-accent-foreground ${activeInsetShadow} ${flatPress}`,
ghost: `border-transparent text-foreground hover:bg-muted ${activeInsetShadow} ${flatPress}`,
destructive: `border-[color-mix(in_oklch,var(--destructive),black_8%)] bg-destructive text-[color:var(--destructive-foreground,white)] ${tactileFilled} ${flatPress}`,
tertiary: `border-transparent bg-accent text-accent-foreground ${activeInsetShadow} ${flatPress}`,
'destructive-soft': `border-transparent bg-destructive/10 text-destructive dark:bg-destructive/20 ${activeInsetShadow} ${flatPress}`,
link: 'border-transparent text-primary underline-offset-4 hover:underline',
} as const;
type ButtonVariant = keyof typeof buttonSurfaces;
const buttonBase = cva(
[
// layout
'group/button relative isolate inline-flex shrink-0 items-center justify-center whitespace-nowrap rounded-lg border text-sm font-medium',
// interaction
'cursor-pointer select-none touch-manipulation',
'transition-[background-color,border-color,box-shadow,translate,scale,filter] duration-150 ease-out motion-reduce:transition-none',
focusRing,
// 44px touch target on coarse pointers without changing the visual size
'[@media(pointer:coarse)]:after:absolute [@media(pointer:coarse)]:after:inset-1/2 [@media(pointer:coarse)]:after:min-h-11 [@media(pointer:coarse)]:after:min-w-11 [@media(pointer:coarse)]:after:-translate-1/2',
// states
'disabled:cursor-not-allowed aria-disabled:opacity-50 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-pending:cursor-wait',
// icons
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-(--icon-size,1rem) [&>span:has(>svg):not([class*='size-'])]:size-(--icon-size,1rem)",
],
{
variants: {
size: {
md: `${controlHeights.md} ${controlTextSizes.md} gap-2 px-4 [--icon-size:1.2rem]`,
xs: `${controlHeights.xs} ${controlTextSizes.xs} gap-1 px-2.5 [--icon-size:0.875rem]`,
sm: `${controlHeights.sm} ${controlTextSizes.sm} gap-1.5 px-3 [--icon-size:1rem]`,
lg: `${controlHeights.lg} ${controlTextSizes.lg} gap-2 px-6 [--icon-size:1.25rem]`,
icon: `${controlHeights.md} aspect-square [--icon-size:1.2rem]`,
'icon-xs': `${controlHeights.xs} aspect-square [--icon-size:0.875rem]`,
'icon-sm': `${controlHeights.sm} aspect-square [--icon-size:1rem]`,
'icon-lg': `${controlHeights.lg} aspect-square [--icon-size:1.25rem]`,
},
},
defaultVariants: { size: 'md' },
},
);
type ButtonVariantProps = VariantProps<typeof buttonBase> & {
variant?: ButtonVariant;
};
function buttonVariants({
variant = 'primary',
size,
className,
}: ButtonVariantProps & { className?: string } = {}) {
return cn(buttonBase({ size }), buttonSurfaces[variant], className);
}
type ButtonProps = Omit<
ComponentProps<typeof ButtonPrimitive>,
keyof ButtonOptions | 'className' | 'children'
> &
ButtonOptions &
ButtonVariantProps & {
children?: ReactNode;
className?: string;
/** Prevent repeated activation and display an inline spinner without replacing the label. */
loading?: boolean;
};
const spinner = (
<Loader2
aria-hidden="true"
data-slot="spinner"
className="hidden size-(--icon-size,1rem) animate-spin in-data-pending:inline-block in-data-loading:inline-block motion-reduce:animate-none"
/>
);
function Button({
className,
variant = 'primary',
size = 'md',
loading = false,
disabled,
children,
'aria-busy': ariaBusy,
...props
}: ButtonProps) {
return (
<ButtonPrimitive
{...props}
className={buttonVariants({ variant, size, className })}
data-size={size}
data-variant={variant}
data-loading={loading || undefined}
disabled={disabled || loading}
aria-busy={loading || ariaBusy}
>
{spinner}
{children}
</ButtonPrimitive>
);
}
export { Button, type ButtonProps, type ButtonVariant, buttonSurfaces, buttonVariants };
import { Separator as SDKSeparator } from '@ui-sdk/react/separator';
import type { ComponentProps } from 'react';
import { partClass } from '@/lib/devvarena-ui';
type SeparatorProps = ComponentProps<typeof SDKSeparator> & { variant?: 'fade' | 'solid' };
/** Theme-derived fading rule built on `@ui-sdk/react/separator`. */
function Separator({
orientation = 'horizontal',
decorative = true,
variant = 'fade',
className,
...props
}: SeparatorProps) {
return (
<SDKSeparator
{...props}
orientation={orientation}
decorative={decorative}
data-variant={variant}
className={partClass(
'pointer-events-none shrink-0',
orientation === 'horizontal' ? 'h-px w-full' : 'w-px self-stretch',
variant === 'solid'
? 'bg-[var(--separator-color,var(--border))]'
: orientation === 'horizontal'
? 'bg-[linear-gradient(to_right,transparent,var(--separator-color,var(--border))_18%,var(--separator-color,var(--border))_82%,transparent)]'
: 'bg-[linear-gradient(to_bottom,transparent,var(--separator-color,var(--border))_18%,var(--separator-color,var(--border))_82%,transparent)]',
className,
)}
/>
);
}
export type { SeparatorProps };
export { Separator };
import { cn } from '@/lib/utils';
type ClassValue = string | false | null | undefined;
type PartClassValue<State> = ClassValue | ((state: State) => ClassValue);
/** Composes static class names and UI-SDK state class functions into a single `className` prop. */
export function partClass<State>(...parts: PartClassValue<State>[]) {
if (parts.some((part) => typeof part === 'function')) {
return (state: State) =>
cn(...parts.map((part) => (typeof part === 'function' ? part(state) : part)));
}
return cn(...(parts as ClassValue[]));
}
export const surfacePadding = 'p-1 [--surface-padding:1.5rem] [--concentric-inset:0.25rem]';
export const surfaceRegionInset = 'p-[calc(var(--surface-padding,1rem)-0.5rem)]';
export const surfaceHeaderRadius = 'rounded-t-[max(0px,calc(var(--radius-lg,0.5rem)-0.25rem))]';
export const surfaceFooterRadius = 'rounded-b-[max(0px,calc(var(--radius-lg,0.5rem)-0.25rem))]';
/** Concentric inner radius (`outer - inset`); set `[--concentric-inset:0.125rem]` on `p-0.5` rails (defaults to `0.25rem` for `p-1`). */
export const concentricRadius =
'rounded-[max(0px,calc(var(--radius-lg,0.5rem)-var(--concentric-inset,0.25rem)))]';
export const surfaceBodyPadding =
'py-[max(0px,calc(var(--surface-padding,1rem)-1rem))] has-[>[data-slot=list]:not([data-variant=plain])]:p-0 has-[>[data-slot=list-items-container]]:p-0';
export type StandardControlSize = 'xs' | 'sm' | 'md' | 'lg';
/** Standard control heights (`28px / 32px / 40px / 48px`) for buttons, inputs, selects, tabs, and sliders. */
export const controlHeights = {
xs: 'h-7',
sm: 'h-8',
md: 'h-10',
lg: 'h-12',
} as const satisfies Record<StandardControlSize, string>;
/** Standard minimum control heights (`28px / 32px / 40px / 48px`) for expandable controls and menu items. */
export const controlMinHeights = {
xs: 'min-h-7',
sm: 'min-h-8',
md: 'min-h-10',
lg: 'min-h-12',
} as const satisfies Record<StandardControlSize, string>;
/** Standard control text sizes (`xs / xs / sm / base`) paired with `StandardControlSize`. */
export const controlTextSizes = {
xs: 'text-xs',
sm: 'text-xs',
md: 'text-sm',
lg: 'text-base',
} as const satisfies Record<StandardControlSize, string>;
/** Compact control heights (`1.25rem / 1.3rem / 1.625rem / 1.75rem`), one step smaller than standard, for switches and compact controls. */
export const compactControlHeights = {
xs: 'h-[1.3rem]',
sm: 'h-[1.4rem]',
md: 'h-[1.5rem]',
lg: 'h-[1.6rem]',
} as const satisfies Record<StandardControlSize, string>;
/** Compact minimum control heights (`1rem / 1.25rem / 1.5rem / 1.75rem`) for badges and tooltips. */
export const compactControlMinHeights = {
xs: 'min-h-[1.3rem]',
sm: 'min-h-[1.4rem]',
md: 'min-h-[1.5rem]',
lg: 'min-h-[1.6rem]',
} as const satisfies Record<StandardControlSize, string>;
/** Universal keyboard focus + invalid ring/border styles shared across controls. */
export const focusRing =
'touch-manipulation outline-none focus-visible:border-ring/30 transition-ring focus-visible:ring-3 focus-visible:ring-ring/15 focus-visible:brightness-[0.97] dark:focus-visible:brightness-[1.15] has-[:focus-visible]:border-ring/30 has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/15 has-[:focus-visible]:brightness-[0.97] dark:has-[:focus-visible]:brightness-[1.15] data-active:border-ring/30 data-active:ring-3 data-active:ring-ring/15 data-active:brightness-[0.97] dark:data-active:brightness-[1.15] data-open:border-ring/30 data-open:ring-3 data-open:ring-ring/15 data-open:brightness-[0.97] dark:data-open:brightness-[1.15] data-disabled:cursor-not-allowed data-disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/25 data-invalid:border-destructive data-invalid:ring-3 data-invalid:ring-destructive/25 has-[[data-invalid]]:border-destructive has-[[data-invalid]]:ring-3 has-[[data-invalid]]:ring-destructive/25 group-aria-invalid/control:border-destructive group-aria-invalid/control:ring-3 group-aria-invalid/control:ring-destructive/25 group-data-invalid/control:border-destructive group-data-invalid/control:ring-3 group-data-invalid/control:ring-destructive/25 group-has-[input[aria-invalid=true]]/control:border-destructive group-has-[input[aria-invalid=true]]/control:ring-3 group-has-[input[aria-invalid=true]]/control:ring-destructive/25 hover:brightness-[0.97] dark:hover:brightness-[1.15]';
/** Shared sliding highlight indicator base (pointer-safe, concentric inner radius inside rounded-lg containers, 200ms transition). */
export const slidingHighlight =
'pointer-events-none -z-10 rounded-[max(0px,calc(var(--radius-lg,0.5rem)-var(--concentric-inset,0.25rem)))] bg-primary/10 [clip-path:inset(0px_round_max(0px,calc(var(--radius-lg,0.5rem)-var(--concentric-inset,0.25rem))))] transition-[transform,width,height,opacity] duration-200 ease-out motion-reduce:transition-none';
export const textFieldSurfaces = {
filled: 'border-input bg-card text-card-foreground',
outline: 'border-input bg-transparent text-foreground dark:bg-transparent',
ghost: 'border-transparent bg-muted text-foreground shadow-none',
underline:
'rounded-none border-0 border-b-2 border-input bg-transparent px-0 text-foreground shadow-none focus-visible:border-ring focus-visible:ring-0 aria-invalid:ring-0 data-invalid:ring-0 dark:bg-transparent',
} as const;
export const textFieldUnderlineMotion =
'border-transparent! bg-origin-border bg-bottom bg-no-repeat [--underline-color:var(--primary)] [background-image:linear-gradient(var(--underline-color),var(--underline-color)),linear-gradient(var(--input),var(--input))] [background-size:0%_2px,100%_2px] focus:[background-size:100%_2px,100%_2px] aria-invalid:[--underline-color:var(--destructive)] data-invalid:[--underline-color:var(--destructive)] transition-[border-color,background-color,box-shadow,filter,background-size] duration-200 motion-reduce:transition-none';
/** Generic balanced icon & floating-label layout tokens shared across all text-field sizes. */
export const textFieldLayout = {
icon: 'size-4',
iconStart: 'start-3',
iconEnd: 'end-3',
padStart: 'ps-9',
padEnd: 'pe-9',
underlinePadStart: 'ps-7',
underlinePadEnd: 'pe-7',
floatingStart: 'start-2.5',
floatingWithIcon: 'start-8',
floatingUnderlineIcon: 'start-6',
} as const;
export const textFieldLabelSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
/** Clamps per-grapheme wave delay (ms) so total staggering stays within 300ms. */
export function clampWaveDelay(waveDelay: number, count: number): number {
return Math.max(
0,
Math.min(Number.isFinite(waveDelay) ? waveDelay : 24, 80, 300 / Math.max(1, count - 1)),
);
}
/** Shared scale/color transition for floating labels inside a `group/field` wrapper. */
export const textFieldLabelMotion =
'inline-block origin-left backdrop-blur-xs transition-[scale,color] duration-200 ease-out group-has-[input:focus]/field:scale-85 group-has-[input:not(:placeholder-shown)]/field:scale-85 rtl:origin-right motion-reduce:transition-none';
/** Resolves start/end padding for a text field when a leading or trailing icon is present. */
export function getTextFieldIconPadding(iconPosition: 'start' | 'end', underline: boolean): string {
if (iconPosition === 'start') {
return underline ? textFieldLayout.underlinePadStart : textFieldLayout.padStart;
}
return underline ? textFieldLayout.underlinePadEnd : textFieldLayout.padEnd;
}
/** Shared per-grapheme ripple transition for wave labels inside a `group/field` wrapper. */
export const textFieldWaveMotion =
'inline-block origin-left backdrop-blur-xs transition-[translate,scale,color] duration-200 ease-out group-has-[input:focus]/field:-translate-y-5 group-has-[input:focus]/field:scale-85 group-has-[input:focus]/field:text-primary group-has-[input:not(:placeholder-shown)]/field:-translate-y-5 group-has-[input:not(:placeholder-shown)]/field:scale-85 group-has-[input[aria-invalid=true]]/field:text-destructive rtl:origin-right motion-reduce:transition-none';