shadcn-ui/ui · error

Unknown preset: ${presetArg}

Error message

Unknown preset: ${presetArg}

What it means

When `shadcn init` receives a preset argument that is neither a URL, a valid preset code, nor a key in presetsByName, the lookup fails and throws. The preset arg selects which built-in design-system preset to initialize from.

Source

Thrown at packages/shadcn/src/commands/init.ts:454

            // Preset codes no longer carry base, so use "base" as placeholder.
            // The correct base is set in the URL after resolution below.
            initUrl = resolveInitUrl(
              {
                ...decoded,
                base: "base",
                rtl: options.rtl ?? false,
              },
              {
                template: options.template,
                preset: presetArg,
                pointer: options.pointer,
              }
            )
            presetBase = undefined
          } else {
            const preset = presetsByName.get(presetArg)
            if (!preset) {
              throw new Error(`Unknown preset: ${presetArg}`)
            }
            initUrl = resolveInitUrl(
              {
                ...preset,
                base: options.base ?? "base",
                rtl: options.rtl ?? preset.rtl,
              },
              { template: options.template, pointer: options.pointer }
            )
            presetBase = undefined
          }

          components = [initUrl, ...components]
        }
      }

      // Resolve base: --base flag > preset/prompt/URL > existing config > prompt.
      let resolvedBase: PresetBase | undefined =

View on GitHub (pinned to efac598707)

Solutions

  1. Use the preset's URL form instead: `shadcn init -p https://ui.shadcn.com/...`.
  2. Use a preset code generated at ui.shadcn.com/create.
  3. Check the preset slug against your shadcn version's presets list (or `shadcn init --help`).
  4. Upgrade or downgrade shadcn to the version that ships the preset you need.
Defensive patterns

Strategy: validation

Validate before calling

import { isUrl } from "@/utils/is-url"
import { isPresetCode } from "@/preset/preset"

function assertKnownPresetArg(arg: string, presetsByName: Map<string, unknown>) {
  if (isUrl(arg) || isPresetCode(arg) || presetsByName.has(arg)) return
  throw new Error(`Unknown preset: ${arg}. Use a URL, code, or one of: ${[...presetsByName.keys()].join(", ")}`)
}

Type guard

function isKnownPresetSlug(arg: string, presetsByName: Map<string, unknown>): boolean {
  return presetsByName.has(arg)
}

Prevention

When it happens

Trigger: Running `shadcn init -p <name>` (or --preset) where <name> isn't in the built-in presetsByName map for the installed CLI version, after the URL and preset-code branches have already been ruled out.

Common situations: Typo in the preset slug, preset renamed or removed in a newer shadcn version, using a preset name copied from outdated docs, pasting the preset's display label instead of its slug.

Related errors


AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12). Data as JSON: /api/errors/442f2f6628150407. Report an issue: GitHub.