Skip to content
Design System
GitHub

Migrating from local components

A product that built its own page header, metric card or status dot moves to the kit's: set up the registry, run the codemod, then finish by hand what it lists. Written for the LocalMind Portal's components/common; any shadcn new-york product maps the same way.

Set up the registry

Add @syncrobotic beside the product's own registry in components.json, then the theme and the items the codemod moves.

components.json
{
  "registries": {
    "@localmind": "https://localmind.xyz/r/{name}.json",
    "@syncrobotic": "https://design-system.syncrobotic.me/r/{name}.json"
  }
}
Terminal
npx shadcn add @syncrobotic/syncrobotic-theme
npx shadcn add @syncrobotic/status-glyph @syncrobotic/page-header @syncrobotic/section-header @syncrobotic/metric-card @syncrobotic/empty-state

Import the theme in globals.css, delete the product's own :root, .dark, .light and @theme inline colour blocks, and keep the brand in the brand layer. node scripts/brand.mjs src/app/globals.css lists every theme token still redefined and every brand pair below its contrast.

The kit installs into the same folders. In the Portal, card, button, alert-dialog, calendar, label and popover already exist in components/ui, and @syncrobotic/cn writes lib/utils.ts, which would shadow lib/utils/index.ts. The CLI asks before it overwrites: decline cn (the same function) and take the others one at a time, on purpose: the kit's Button is primary, secondary, outline, not default.

The brand: Design tokens, brand layer. Statuses: healthy is grey.

Order

  1. Theme and brand. No call site changes; the product looks like the kit in its own purple.
  2. Statuses: StatusDot to StatusGlyph, and status-tone.ts to the decision record's table. Grey when healthy.
  3. The codemod: PageHeader, SectionHeader and Section, MetricCard, EmptyState, StatusDot.
  4. By hand: DetailField, ConfirmDialog, DateRangeField, and the notes the codemod printed.
  5. Delete the local files. npm run adoption -- ../portal lists every look-alike still defined, with its kit item.

Codemod

Terminal
# In a checkout of the design system, next to the product's
node scripts/codemods/portal-to-kit.mjs ../portal/src           # dry run: a diff and the notes, nothing written
node scripts/codemods/portal-to-kit.mjs ../portal/src --write   # apply
npm run adoption -- ../portal                                  # what is left: every look-alike still defined

It parses each file with the TypeScript compiler and changes only what it touches: the imports (to @/components/ui/<item>, StatusGlyph to @/components/status-glyph; --ui, --components and --link-from follow other aliases), the renamed props, StatusDot's statuses where every value is written in the file, EmptyState's action, Section's wrapper, and the imports a dropped prop leaves unused. Each dropped prop and each thing left to do is printed with its file and line.

What it cannot do: rebuild PageHeader's actions and back, merge a grid of DetailFields into one list, rewrite a ConfirmDialog or a DateRangeField, map a status that comes from a variable, follow relative imports or spread props, or decide whether a pending state waits on a person or a process. Formatting is left to the product's formatter.

LocalKitHow
title, description, classNamethe sameThe title is an h1; as="h2" under another h1.
badgebadgesA state (online, revoked) goes in status as one InlineStatus, not in a badge. Codemod.
back={{ href, label }}breadcrumbA Breadcrumb ending at the parent page.
actions={{ primary, secondary }}actionsThe buttons themselves: a primary Button and secondary ones; more than two fold into a DropdownMenu with DropdownMenuMoreTrigger.
icon, avatar, avatarUrl, avatarFallback, colorThemenoneDropped: the breadcrumb says where, the title says what. Codemod.
(none)meta, statusFacts as MetaPills (counts, owner, last update); the page's state as InlineStatus.

MetricCard

LocalKitHow
label, valuethe sameThe value already formatted (formatCount).
descriptioncaptionCodemod.
isLoadingloadingCodemod.
internalHrefhref with linkAs={Link}Codemod, importing your router's Link.
href (a new tab)noneThe kit's href stays in the tab; link to a page of your own.
valueClassName (a colour)tonewarning or danger, with the reason in caption. The value stays ink.
footer (a sparkline)seriesThe last values, oldest first.
icon, compactnoneDropped; MetricGrid lays out the row. Codemod.
onClicknoneA card is a link or nothing: a Button in caption, or a page.
(none)unit, delta, trend, unavailableunavailable shows a dash and why, never a made-up 0.

SectionHeader, Section and SubsectionHeader

LocalKitHow
SectionHeader title, descriptionthe same16 px bold h2, outside cards.
actionactionsCodemod.
Section (header and children)<section> with SectionHeader firstCodemod: gap-3, a className merged with cn.
SubsectionHeaderSectionHeader variant="surface"14 px medium h3, inside a card. Codemod.
icon, tone, iconClassName, alignnoneDropped: a heading is never coloured; say the state in words. Codemod.
(none)count, as, idcount is written in full (1,284).

DetailField to DescriptionList

LocalKitHow
a grid of DetailFieldsone DescriptionListitems={[{ label, value, … }]} with columns (1–4) and variant (plain in a card, bare on one).
label, childrenlabel, valueAn empty value is a dash, heard as Not set.
hint, mono, iconthe sameOn the item.
hintAs="tooltip"noneThe hint is always under the value.
(none)copyA copy button after an id or a fingerprint.

EmptyState

LocalKitHow
title, description, icon, classNamethe sameThe kit draws no icon by default (the Portal drew a Box).
actionLabel with actionHref or onActionactionThe Button itself. Codemod.
eyebrownoneDropped. Codemod.
(none)size, variantinline in a table or list; overlay over a canvas.

ConfirmDialog to AlertDialog

LocalKitHow
open, onOpenChangeAlertDialogThe same props.
title, descriptionAlertDialogTitle, AlertDialogDescriptionThe title is the question.
confirmLabel, cancelLabelthe children of AlertDialogAction, AlertDialogCancelRequired: name the consequence ("Revoke key"), never "Confirm".
variant="destructive"AlertDialogAction destructiveThe danger outline; never solid red.
isLoading, confirmDisabled, confirmIcona Button inside AlertDialogAction asChildloading, disabled, the icon as a child.
DeleteConfirmDialogthe destructive confirm patternWhat is lost, who it affects, the name typed for the worst cases.
InlineConfirmDialog triggerAlertDialogTrigger asChildUncontrolled.

To move the look before the call sites, keep the props and build them on the kit's parts:

components/common/confirm-dialog.tsx
"use client"

import * as React from "react"
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
} from "@/components/ui/alert-dialog"
import { Button } from "@/components/ui/button"

// The Portal's ConfirmDialog props on the kit's AlertDialog, so its call sites keep working while the look moves to the
// kit. The words are required: the confirm names the consequence ("Revoke key"), never "Confirm".
export function ConfirmDialog({
  open,
  onOpenChange,
  title,
  description,
  confirmLabel,
  cancelLabel,
  variant = "default",
  isLoading = false,
  confirmDisabled = false,
  confirmIcon,
  onConfirm,
  children,
}: {
  open: boolean
  onOpenChange: (open: boolean) => void
  title: string
  description?: string
  confirmLabel: string
  cancelLabel: string
  variant?: "default" | "destructive"
  isLoading?: boolean
  confirmDisabled?: boolean
  confirmIcon?: React.ReactNode
  onConfirm: () => void
  children?: React.ReactNode
}) {
  return (
    <AlertDialog open={open} onOpenChange={onOpenChange}>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>{title}</AlertDialogTitle>
          {description && <AlertDialogDescription>{description}</AlertDialogDescription>}
        </AlertDialogHeader>
        {children}
        <AlertDialogFooter>
          <AlertDialogCancel disabled={isLoading}>{cancelLabel}</AlertDialogCancel>
          <AlertDialogAction asChild>
            {/* The danger outline for a destructive confirm: solid red is the emergency stop's alone. */}
            <Button
              variant={variant === "destructive" ? "destructive" : "primary"}
              loading={isLoading}
              disabled={confirmDisabled}
              onClick={onConfirm}
            >
              {!isLoading && confirmIcon}
              {confirmLabel}
            </Button>
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  )
}

DateRangeField to DateRangePicker

LocalKitHow
from, to (YYYY-MM-DD)value ({ from?: Date, to?: Date })parseISO in, format(d, "yyyy-MM-dd") out, for the URL.
onFromChange, onToChangeonValueChange(range)One callback for the range.
labela Field label, or aria-labelWhich date the range bounds.
the clear buttonclearable
to not before frombuilt inA range calendar cannot pick it.
(none)presets, locale, labelsdatePickerLabels from labels-zh-tw.

StatusDot to StatusGlyph

LocalKitHow
status="online"status="normal"Codemod.
status="pending"status="warning"Waiting on a person: warning. Waiting on a process: active. Codemod picks warning.
status="error"status="danger"Codemod.
status="info"status="active"Codemod.
status="offline"status="offline"Codemod.
size, pulsenone12 px; loops are only for waiting. Dropped. Codemod.
a colour onlya shape, and the word beside itThe glyph is hidden from screen readers: write the status (InlineStatus draws both).

No equivalent yet

  • A page icon or avatar in the header, coloured icon tiles (colorTheme), and a stat card's icon: left out on purpose, colour is for what is abnormal.
  • A metric card that opens a dialog (onClick) or a new tab, and a hint folded into a tooltip (hintAs).
  • The brand tone of status-tone.ts: a role or a plan is a fixed attribute, an outline Badge, not a state.
  • String dates in a date range: the picker takes Dates; the URL keeps the strings.