Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@clack/prompts

bombshell-dev5mMIT0.11.0TypeScript support: included

Effortlessly build beautiful command-line apps 🪄 Try the demo

ask, clack, cli, command-line, command, input, interact, interface, menu, prompt, prompts, stdin, ui

readme



<picture> <source media="(prefers-color-scheme: dark)" srcset="/.github/assets/clack-dark.gif?sanitize=true"> Clack logo </picture>

Effortlessly build beautiful command-line apps 🪄

@clack/core: unstyled, extensible primitives for CLIs

@clack/prompts: beautiful, ready-to-use CLI prompt components

[!WARNING] Clack's main branch is tracking the alpha release line for v1.0.0+. To view the relatively stable v0 line, please browse the v0 branch.



@clack/prompts in action

changelog

@clack/prompts

0.11.0

Minor Changes

  • 07ca32d: Reverted a change where placeholders were being set as values on return.

Patch Changes

0.10.1

Patch Changes

  • 11a5dc1: Fixes multiselect only shows hints on the first item in the options list. Now correctly shows hints for all selected options with hint property.
  • 30aa7ed: Adds a new selectableGroups boolean to the group multi-select prompt. Using selectableGroups: false will disable the ability to select a top-level group, but still allow every child to be selected individually.
  • Updated dependencies [30aa7ed]
  • Updated dependencies [5dfce8a]
  • Updated dependencies [f574297]

0.10.0

Minor Changes

  • 613179d: Adds a new indicator option to spinner, which supports the original "dots" loading animation or a new "timer" loading animation.

    import * as p from "@clack/prompts";
    
    const spin = p.spinner({ indicator: "timer" });
    spin.start("Loading");
    await sleep(3000);
    spin.stop("Loaded");
  • a38b2bc: Adds stream API which provides the same methods as log, but for iterable (even async) message streams. This is particularly useful for AI responses which are dynamically generated by LLMs.

    import * as p from "@clack/prompts";
    
    await p.stream.step(
      (async function* () {
        yield* generateLLMResponse(question);
      })()
    );

0.9.1

Patch Changes

  • 8093f3c: Adds Error support to the validate function
  • 98925e3: Exports the Option type and improves JSDocannotations
  • 1904e57: Replace custom utility for stripping ANSI control sequences with Node's built-in stripVTControlCharacters utility.
  • Updated dependencies [8093f3c]
  • Updated dependencies [e5ba09a]
  • Updated dependencies [8cba8e3]

0.9.0

Minor Changes

  • a83d2f8: Adds a new updateSettings() function to support new global keybindings.

    updateSettings() accepts an aliases object that maps custom keys to an action (up | down | left | right | space | enter | cancel).

    import { updateSettings } from "@clack/prompts";
    
    // Support custom keybindings
    updateSettings({
      aliases: {
        w: "up",
        a: "left",
        s: "down",
        d: "right",
      },
    });

[!WARNING] In order to enforce consistent, user-friendly defaults across the ecosystem, updateSettings does not support disabling Clack's default keybindings.

  • 801246b: Adds a new signal option to support programmatic prompt cancellation with an abort controller.

    One example use case is automatically cancelling a prompt after a timeout.

    const shouldContinue = await confirm({
      message: "This message will self destruct in 5 seconds",
      signal: AbortSignal.timeout(5000),
    });

    Another use case is racing a long running task with a manual prompt.

    const abortController = new AbortController();
    
    const projectType = await Promise.race([
      detectProjectType({
        signal: abortController.signal,
      }),
      select({
        message: "Pick a project type.",
        options: [
          { value: "ts", label: "TypeScript" },
          { value: "js", label: "JavaScript" },
          { value: "coffee", label: "CoffeeScript", hint: "oh no" },
        ],
        signal: abortController.signal,
      }),
    ]);
    
    abortController.abort();
  • a83d2f8: Updates default keybindings to support Vim motion shortcuts and map the escape key to cancel (ctrl+c).

    | alias | action | | ----- | ------ | | k | up | | l | right | | j | down | | h | left | | esc | cancel |

Patch Changes

  • f9f139d: Adapts spinner output for static CI environments
  • Updated dependencies [a83d2f8]
  • Updated dependencies [801246b]
  • Updated dependencies [a83d2f8]
  • Updated dependencies [51e12bc]

0.8.2

Patch Changes

  • Updated dependencies [4845f4f]
  • Updated dependencies [d7b2fb9]

0.8.1

Patch Changes

  • 360afeb: feat: adaptative max items

0.8.0

Minor Changes

  • 9acccde: Add tasks function for executing tasks in spinners

Patch Changes

  • b5c6b9b: Feat multiselect maxItems option
  • 50ed94a: fix: clear spinner hooks on spinner.stop
  • Updated dependencies [a04e418]
  • Updated dependencies [4f6fcf5]

0.7.0

Minor Changes

  • b27a701: add maxItems option to select prompt
  • 89371be: added a new method called spinner.message(msg: string)

Patch Changes

  • 52183c4: Fix spinner conflict with terminal on error between spinner.start() and spinner.stop()
  • ab51d29: Fixes cases where the note title length was miscalculated due to ansi characters
  • Updated dependencies [cd79076]

0.6.3

Patch Changes

  • c96eda5: Enable hard line-wrapping behavior for long words without spaces
  • Updated dependencies [c96eda5]

0.6.2

Patch Changes

  • 58a1df1: Fix line duplication bug by automatically wrapping prompts to process.stdout.columns
  • Updated dependencies [58a1df1]

0.6.1

Patch Changes

  • ca08fb6: Support complex value types for select, multiselect and groupMultiselect.

0.6.0

Minor Changes

  • 8a4a12f: add groupMultiselect prompt
  • 165a1b3: Add log APIs. Supports log.info, log.success, log.warn, and log.error. For low-level control, log.message is also exposed.

Patch Changes

  • Updated dependencies [8a4a12f]
  • Updated dependencies [8a4a12f]

0.5.1

Patch Changes

  • cc11917: Update default password mask
  • Updated dependencies [ec812b6]

0.5.0

Minor Changes

  • d74dd05: Adds a selectKey prompt type
  • 54c1bc3: Breaking Change multiselect has renamed initialValue to initialValues

Patch Changes

  • Updated dependencies [d74dd05]
  • Updated dependencies [54c1bc3]

0.4.5

Patch Changes

  • 1251132: Multiselect: return Value[] instead of Option[].
  • 8994382: Add a password prompt to @clack/prompts
  • Updated dependencies [1251132]
  • Updated dependencies [8994382]

0.4.4

Patch Changes

  • d96071c: Don't mutate initialValue in multiselect, fix parameter type for validate().

    Credits to @banjo for the bug report and initial PR!

  • Updated dependencies [d96071c]

0.4.3

Patch Changes

  • 83d890e: Fix text cancel display bug

0.4.2

Patch Changes

  • Update README

0.4.1

Patch Changes

  • 7fb5375: Adds a new defaultValue option to the text prompt, removes automatic usage of the placeholder value.
  • Updated dependencies [7fb5375]

0.4.0

Minor Changes

  • 61b88b6: Add group construct to group many prompts together

Patch Changes

  • de1314e: Support required option for multi-select
  • Updated dependencies [de1314e]

0.3.0

Minor Changes

  • 493c592: Improve types for select/multiselect prompts. Numbers and booleans are now supported as the value option.
  • 15558e3: Improved Windows/non-unicode support

Patch Changes

  • ca77da1: Fix multiselect initial value logic
  • Updated dependencies [ca77da1]
  • Updated dependencies [8aed606]

0.2.2

Patch Changes

  • 94b24d9: Fix CJS ansi-regex interop

0.2.1

Patch Changes

  • a99c458: Support initialValue option for text prompt
  • Updated dependencies [a99c458]

0.2.0

Minor Changes

  • Improved type safety
  • b1341d6: Updated styles, new note component

Patch Changes

  • Updated dependencies [7dcad8f]
  • Updated dependencies [2242f13]
  • Updated dependencies [b1341d6]

0.1.1

Patch Changes

  • fa09bf5: Use circle for radio, square for checkbox
  • Updated dependencies [4be7dbf]
  • Updated dependencies [b480679]

0.1.0

Minor Changes

  • 7015ec9: Create new prompt: multi-select

Patch Changes

0.0.10

Patch Changes

  • e0b49e5: Update spinner so it actually spins

0.0.9

Patch Changes

  • Update README

0.0.8

Patch Changes

0.0.7

Patch Changes

  • Update README

0.0.6

Patch Changes

  • d20ef2a: Update keywords, URLs
  • Updated dependencies [441d5b7]
  • Updated dependencies [d20ef2a]
  • Updated dependencies [fe13c2f]

0.0.5

Patch Changes

  • Update README

0.0.4

Patch Changes

  • 80404ab: Update README

0.0.3

Patch Changes

0.0.2

Patch Changes

0.0.1

Patch Changes