shadcn-ui/ui · error · ApplyOnlyError

Missing preset for --only. Use: shadcn apply <preset> --only

Error message

Missing preset for --only.
Use: shadcn apply <preset> --only theme,font.

What it means

validateApplyOnlyPreset() throws ApplyOnlyError when --only is set but no preset was supplied (positionally or via --preset). Applying a partial preset (only theme and/or font) still requires knowing which preset to read those parts from.

Source

Thrown at packages/shadcn/src/commands/apply.ts:369

        `Invalid value for --only: ${value}.`,
        `Use one or more of: ${APPLY_ONLY_VALUES.join(", ")}.`,
        "Example: shadcn apply <preset> --only theme,font.",
      ].join("\n")
    )
  }

  return Array.from(new Set(parts.map((part) => aliases[part])))
}

export function validateApplyOnlyPreset(options: {
  preset?: string
  only?: ApplyOnlyValue[]
}) {
  if (!options.only || options.preset) {
    return
  }

  throw new ApplyOnlyError(
    [
      "Missing preset for --only.",
      "Use: shadcn apply <preset> --only theme,font.",
    ].join("\n")
  )
}

function resolveApplyRegistryBaseConfig(options: {
  registryBaseConfig: Record<string, unknown> | undefined
  existingConfig: Record<string, unknown>
  only: ApplyOnlyValue[] | undefined
}) {
  if (!options.only || options.only.includes("theme")) {
    return options.registryBaseConfig
  }

  const existingTailwind =
    typeof options.existingConfig.tailwind === "object" &&

View on GitHub (pinned to efac598707)

Solutions

  1. Provide a preset: `shadcn apply <preset> --only theme`.
  2. Drop --only if you want the full default flow.

Example fix

# before
shadcn apply --only theme

# after
shadcn apply <preset> --only theme
Defensive patterns

Strategy: validation

Validate before calling

if (options.only && !options.preset) {
  console.error("Missing preset for --only. Use: shadcn apply <preset> --only theme,font")
  process.exit(1)
}

Type guard

const hasPresetForOnly = (o: { only?: unknown; preset?: string }): boolean =>
  !o.only || Boolean(o.preset)

Try / catch

try {
  validateApplyOnlyPreset(options)
} catch (e) {
  if (e instanceof ApplyOnlyError) {
    // prompt for a preset
  } else throw e
}

Prevention

When it happens

Trigger: `shadcn apply --only theme` with no preset argument; setting only without a preset in a wrapper; assuming --only infers a default preset.

Common situations: Forgetting the preset positional; assuming a default preset applies.

Related errors


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