Theme, accent, and preference toggles composed from Card—docs example only.
Default
Purpose
An appearance settings panel lets people choose a theme, language, accent, and display preferences in one place.
Parts & Composition
Card (title + description) → CardContent (List with ListItems / ListItem rows for language, theme fieldset, accent swatches, and switches) → CardFooter for reset/save and status. Demos import examples/helper.tsx for theme preview radios and accent swatches—not a registry install.
API & Props
| Prop / part | Purpose |
|---|---|
Card | Provides the panel and receives the accessible heading association. |
List.variant | Use plain for preference rows inside the card. |
RadioGroup | Holds the theme and accent selections. Keep both controlled by the same draft as the rest of the form. |
Select / Switch | Use controlled values and connect each control to its visible label. |
Footer actions | Provide reset and save callbacks. The recipe exposes no root props. |
State & Forms
The example keeps draft preferences separate from saved preferences. Theme, accent, language, and switches commit together on Save; Cancel restores the saved draft, and Reset restores example defaults. The example's i18next instance and theme provider are preview wiring only. Persist preferences through the application that owns the settings.
Theming, Layout & Responsiveness
Theme thumbnails use semantic theme tokens inside light and dark preview scopes. Accent swatches illustrate a selectable palette; selecting one updates the draft but does not change the docs site's theme tokens. Rows stack on narrow screens, and the theme choices remain in a three-column group. The nested List shares the Card surface-padding token so its dividers align with the card regions.
Motion & Accessibility
Use radio groups with visible labels. Associate the card with its title via aria-labelledby. The reduced-motion control reflects the operating system preference and is disabled when the system already requests reduced motion.
Guidance for Coding Agents
Use the Card and List recipe as the layout, then connect the controls to the application's settings state. Keep draft and saved values separate and make save, reset, and error states clear. Keep theme and accent selections controlled so Cancel and Reset restore them with the other fields.
Associate the settings card with its heading via aria-labelledby, and pair every Switch or Select row with a visible label. Place interaction handlers on the controls inside each row.
Install the component parts listed below and start from the closest Preview → Usage example. Use this Info page for the composition and controlled draft pattern. For inherited selection, keyboard, and value behavior, consult the UI SDK Radio, UI SDK Select, and UI SDK Switch references before extending their behavior.
Registry
Install card, list, select, radio, switch, button, and other parts your composition uses. Copy helper.tsx if you want the theme-preview radio options and accent swatches.
CLI installation
bunx --bun shadcn@latest add https://ui.devvarena.com/api/r/cardimport { cva } from 'class-variance-authority';
import type { ComponentProps } from 'react';
import { Separator } from '@/components/devvarena-ui/separator';
import {
type StandardControlSize,
surfaceBodyPadding,
surfaceFooterRadius,
surfaceHeaderRadius,
surfacePadding,
surfaceRegionInset,
} from '@/lib/devvarena-ui';
import { cn } from '@/lib/utils';
const cardSizes = cva(null, {
variants: {
size: {
xs: 'max-w-xs [--surface-padding:1.3rem]',
sm: 'max-w-sm [--surface-padding:1.35rem]',
md: 'max-w-sm',
lg: 'max-w-lg [--surface-padding:1.75rem]',
},
},
});
type CardProps = ComponentProps<'article'> & { size?: StandardControlSize };
/** Compound display surface with elevation and composable regions. */
function Card({ className, children, size = 'md', ...props }: CardProps) {
return (
<article
{...props}
data-slot="card"
data-size={size}
className={cn(
'group/card relative isolate flex w-full min-w-0 flex-col',
surfacePadding,
cardSizes({ size }),
'rounded-lg border border-border bg-card text-card-foreground shadow-sm transition-[box-shadow,border-color] duration-200 hover:shadow-md motion-reduce:transition-none',
className,
)}
>
{children}
</article>
);
}
/** Header row for media, text, and trailing controls. */
function CardHeader({
separator = false,
className,
children,
...props
}: ComponentProps<'header'> & { separator?: boolean }) {
return (
<header
{...props}
data-slot="card-header"
className={cn(
surfaceHeaderRadius,
'[&.sticky]:top-0',
surfaceRegionInset,
'flex items-start justify-between gap-3 relative',
className,
)}
>
{separator ? <Separator className="absolute inset-x-0 bottom-0 w-auto" /> : null}
{children}
</header>
);
}
/** Vertical primary / supporting lines in the header (e.g. company + posted time). */
function CardHeaderText({ className, ...props }: ComponentProps<'div'>) {
return (
<div
{...props}
data-slot="card-header-text"
className={cn('flex min-w-0 flex-1 flex-col', className)}
/>
);
}
function CardHeaderCaption({ className, ...props }: ComponentProps<'div'>) {
return (
<div
{...props}
data-slot="card-header-caption"
className={cn('mt-0.5 text-xs leading-relaxed text-foreground/65', className)}
/>
);
}
function CardMedia({ className, ...props }: ComponentProps<'div'>) {
return (
<div
aria-hidden="true"
{...props}
data-slot="card-media"
className={cn(
'relative isolate flex size-12 shrink-0 items-center justify-center rounded-lg bg-foreground text-xl text-background shadow-[inset_0_1px_0_rgb(255_255_255/0.35),inset_0_-1px_0_rgb(0_0_0/0.2),0_2px_4px_rgb(0_0_0/0.12)] before:pointer-events-none before:absolute before:inset-0 before:rounded-[inherit] before:bg-[linear-gradient(135deg,rgb(255_255_255/0.22),transparent_42%,rgb(0_0_0/0.08))] after:pointer-events-none after:absolute after:inset-x-2 after:top-0 after:h-px after:bg-[linear-gradient(90deg,transparent,rgb(255_255_255/0.65),transparent)] dark:before:opacity-40 dark:after:opacity-40 [&>svg]:relative [&>svg]:size-6 [&>img]:relative [&>img]:size-8 [&>img]:rounded-lg [&>img]:object-contain',
className,
)}
/>
);
}
function CardSubtitle({ className, ...props }: ComponentProps<'div'>) {
return (
<div
{...props}
data-slot="card-subtitle"
className={cn('block max-w-full break-words text-sm font-semibold tracking-tight', className)}
/>
);
}
function CardContent({ className, ...props }: ComponentProps<'div'>) {
return (
<div
{...props}
data-slot="card-content"
className={cn(surfaceRegionInset, 'min-w-0', surfaceBodyPadding, className)}
/>
);
}
function CardTitle({
as: Heading = 'h3',
className,
...props
}: ComponentProps<'h3'> & { as?: 'h2' | 'h3' | 'h4' }) {
return (
<Heading
{...props}
data-slot="card-title"
className={cn(
'm-0 max-w-[22ch] break-words text-xl font-semibold leading-[1.25] tracking-tight text-balance',
className,
)}
/>
);
}
function CardDescription({ className, ...props }: ComponentProps<'div'>) {
return (
<div
{...props}
data-slot="card-description"
className={cn('mt-2 text-sm leading-relaxed text-muted-foreground', className)}
/>
);
}
/** Footer row for metadata and actions. */
function CardFooter({
separator = true,
className,
children,
...props
}: ComponentProps<'footer'> & { separator?: boolean }) {
return (
<footer
{...props}
data-slot="card-footer"
className={cn(
surfaceFooterRadius,
'relative [&.sticky]:bottom-0 mt-0',
surfaceRegionInset,
'flex flex-col items-stretch justify-between gap-4 md:flex-row md:flex-wrap md:items-center md:gap-3',
className,
)}
>
{separator ? <Separator className="absolute inset-x-0 top-0 w-auto" /> : null}
{children}
</footer>
);
}
function CardActions({ className, ...props }: ComponentProps<'div'>) {
return (
<div
{...props}
data-slot="card-actions"
className={cn('w-full flex-1 min-w-0 flex-wrap items-stretch gap-2 flex', className)}
/>
);
}
export {
Card,
CardActions,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardHeaderCaption,
CardHeaderText,
CardMedia,
CardSubtitle,
CardTitle,
};
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';