shadcn-ui/ui · error · ApplyOnlyError

Invalid value for --only: ${value}. Use one or more of: ${AP

Error message

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

What it means

parseApplyOnlyParts() splits the --only value on commas, lowercases and trims, and rejects anything not in {theme, font, fonts} (fonts is an alias for font). Empty token lists or any unknown token cause an ApplyOnlyError.

Source

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

  }

  return parseApplyOnlyParts(value)
}

export function parseApplyOnlyParts(value: string) {
  const aliases: Record<string, ApplyOnlyValue> = {
    theme: "theme",
    font: "font",
    fonts: "font",
  }
  const parts = value
    .split(",")
    .map((part) => part.trim().toLowerCase())
    .filter(Boolean)
  const invalid = parts.filter((part) => !aliases[part])

  if (!parts.length || invalid.length) {
    throw new ApplyOnlyError(
      [
        `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
  }

View on GitHub (pinned to efac598707)

Solutions

  1. Use only theme and/or font (fonts is accepted as an alias).
  2. Trim stray commas; pass e.g. --only theme,font.

Example fix

# before
shadcn apply <preset> --only colors,theme

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

Strategy: validation

Validate before calling

const ALLOWED = new Set(["theme", "font", "fonts"])
const parts = value.split(",").map((p) => p.trim().toLowerCase()).filter(Boolean)
const invalid = parts.filter((p) => !ALLOWED.has(p))
if (!parts.length || invalid.length) {
  // print guidance before calling the CLI
}

Type guard

const isApplyOnlyPart = (p: string): boolean =>
  ["theme", "font", "fonts"].includes(p.trim().toLowerCase())

Try / catch

try {
  parseApplyOnlyParts(value)
} catch (e) {
  if (e instanceof ApplyOnlyError) {
    // guide the user; offer the valid values
  } else throw e
}

Prevention

When it happens

Trigger: `--only colors`; `--only theme,colors`; `--only ,`; `--only ""`; using a removed token name.

Common situations: Misspelling a part; passing an old or removed token; trailing commas producing empty parts.

Related errors


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