···476476477477### Date input
478478479479-`date` returns a `Date` on success or a cancel symbol. Use `format` to pick segment order: `YMD`, `MDY`, or `DMY`. Pass `locale` (BCP 47 string) to derive order and separators from `Intl`, or rely on the format alone.
479479+The `date` prompt provides an interactive date picker, allowing users to navigate between year, month, and day segments and increment/decrement values using keyboard controls.
480480481481```ts twoslash
482482-import { date, isCancel } from '@clack/prompts';
482482+import { date } from '@clack/prompts';
483483484484-const picked = await date({
485485- message: 'Pick a date',
486486- format: 'YMD',
487487- minDate: new Date('2026-01-01'),
488488- maxDate: new Date('2026-12-31'),
484484+const birthday = await date({
485485+ message: 'Pick your birthday',
486486+ minDate: new Date('1900-01-01'),
487487+ initialValue: new Date(),
488488+ maxDate: new Date(),
489489});
490490-491491-if (isCancel(picked)) {
492492- process.exit(0);
493493-}
494494-495495-// picked is a Date
496490```
497491498498-Options include `defaultValue`, `initialValue`, `minDate`, `maxDate`, `validate`, and the usual `signal`, `input`, `output`, and `withGuide` settings.
492492+Options:
493493+494494+- `message`: The message or question shown to the user above the input.
495495+- `format`: The date format to use (default: based on `locale`).
496496+- `locale`: The [BCP 47 language tag](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag) to use for formatting.
497497+- `defaultValue`: The default value returned when the user doesn't select a date.
498498+- `initialValue`: The starting date shown when the prompt first renders. Users can edit this value before submitting.
499499+- `minDate`: The minimum allowed date for validation.
500500+- `maxDate`: The maximum allowed date for validation.
501501+- `validate`: A function or a [Standard Schema](https://github.com/standard-schema/standard-schema) that validates user input. If a custom function is given, you should return a `string` or `Error` to show as a validation error, or `undefined` to accept the result..
502502+- All [Common Options](#common-options)
499503500504### Confirmation
501505···701705702706<pre class="cli-preview"><font color="#555753">┌</font> Welcome to clack</pre>
703707708708+Options:
709709+710710+- All [Common Options](#common-options)
711711+704712### Outro
705713706714The `outro` function defines the end of an interaction.
···716724<font color="#555753">└</font> All operations are finished
717725 </pre>
718726727727+Options:
728728+729729+- All [Common Options](#common-options)
730730+719731### Cancel
720732721733The `cancel` function defines an interruption of an interaction and therefore its end.
···723735724736```ts twoslash
725737import { cancel } from '@clack/prompts';
738738+import process from 'node:process';
726739727740cancel('Installation canceled');
741741+process.exit(1);
728742```
729743730744<pre class="cli-preview"><font color="#555753">└</font> <font color="#CC0000">Installation canceled</font>
731745 </pre>
746746+747747+Options:
748748+749749+- All [Common Options](#common-options)
732750733751### Spinner
734752···1167118511681186### limitOptions
1169118711701170-`limitOptions` trims a long option list to what fits the terminal, returning the lines to render and keeping the active index visible—intended for **custom** prompts that mirror Clack’s sliding window (see `@clack/prompts` source). Pass `options`, `cursor`, a `style` callback, optional `maxItems`, `columnPadding`, `rowPadding`, and `output` if not using `stdout`.
11881188+Trims an option list to what fits the terminal, while keeping the active option (cursor) visible using a Clack style sliding window. Returns the lines to render.
1171118911721190```ts twoslash
11731191import { limitOptions } from '@clack/prompts';
···11771195const lines = limitOptions({
11781196 options,
11791197 cursor: 2,
11981198+ maxItems: 8,
11801199 style: (opt, active) =>
11811200 active ? styleText('cyan', opt) : styleText('dim', opt),
11821182- maxItems: 8,
11831201});
11841202```
12031203+12041204+Options:
12051205+12061206+- `options`: The list of options to display.
12071207+- `cursor`: The index of the currently active/selected option.
12081208+- `style`: A function that styles the given option string. The `active` parameter indicates whether the option is currently selected.
12091209+- `maxItems`: Maximum number of options to display at once (default: `Infinity`).
12101210+- `columnPadding`: Number of columns to reserve for padding (default: `0`).
12111211+- `rowPadding`: Number of rows to reserve for padding (default: `0`).
12121212+- All [Common Options](#common-options)