shadcn-ui/ui · error · ApplyOnlyError

Missing value for --only. Use one or more of: ${APPLY_ONLY_V

Error message

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

What it means

resolveApplyOnly() throws ApplyOnlyError when the --only flag is present as a bare boolean (true) with no value. `shadcn apply` requires --only to take one or more of the allowed values (theme, font), so a bare flag is treated as a usage error.

Source

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

  }

  const url = new URL(preset)
  if (url.pathname !== "/init") {
    return undefined
  }

  return url.searchParams.get("only") ?? undefined
}

export function resolveApplyOnly(
  value: z.infer<typeof applyOptionsSchema>["only"]
) {
  if (value === undefined || value === false) {
    return undefined
  }

  if (value === true) {
    throw new ApplyOnlyError(
      [
        "Missing value for --only.",
        `Use one or more of: ${APPLY_ONLY_VALUES.join(", ")}.`,
        "Example: shadcn apply <preset> --only theme,font.",
      ].join("\n")
    )
  }

  return parseApplyOnlyParts(value)
}

export function parseApplyOnlyParts(value: string) {
  const aliases: Record<string, ApplyOnlyValue> = {
    theme: "theme",
    font: "font",
    fonts: "font",
  }
  const parts = value

View on GitHub (pinned to efac598707)

Solutions

  1. Provide a value, e.g. --only theme or --only theme,font.
  2. If you meant to apply everything, omit --only entirely.

Example fix

# before
shadcn apply <preset> --only

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

Strategy: validation

Validate before calling

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

Type guard

const hasOnlyValue = (only: unknown): only is string =>
  typeof only === "string" && only.trim() !== ""

Try / catch

try {
  resolveApplyOnly(options.only)
} catch (e) {
  if (e instanceof ApplyOnlyError) {
    // print guidance and exit 1
  } else throw e
}

Prevention

When it happens

Trigger: Running `shadcn apply <preset> --only` with nothing after the flag; a CLI wrapper passing only: true; misusing --only as a boolean toggle.

Common situations: Typing the flag without a value; misunderstanding --only as an on/off switch.

Related errors


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