Skip to content

Styling components

Most styling is a prop. When it isn't, every component takes a className that merges cleanly with its own classes.

Reach for a prop first

// Good: the prop keeps padding on the scale and readable
<Card padding="xl">…</Card>

// Works, but bypasses the scale
<Card className="p-8">…</Card>

className wins on conflicts

Classes are merged with tailwind-merge, so when yours conflicts with a component's default, yours replaces it instead of fighting it on specificity. <Card padding="sm" className="p-6"> renders a single p-6.

Use cn in your own components

import { cn } from "@shavin/ui";

export function Panel({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      className={cn("rounded-[var(--radius-panel)] border border-hairline bg-surface p-5", className)}
      {...props}
    />
  );
}

In a Server Component, import cn from @shavin/ui/server.

Keep values on the tokens

Use token classes (bg-surface, text-fg-subtle, border-hairline) and the radius variables (rounded-[var(--radius-lg)] for controls, rounded-[var(--radius-panel)] for containers). A raw value such as rounded-[12px] or a hex colour will not follow the theme, and the Shavin linters flag it. Inline style is fine for genuinely dynamic values, such as a computed width or a background image URL.

Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font