You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/clack/packages/prompts.mdx
+44-16Lines changed: 44 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -476,26 +476,30 @@ Options:
476
476
477
477
### Date input
478
478
479
-
`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.
479
+
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.
480
480
481
481
```ts twoslash
482
-
import { date, isCancel } from'@clack/prompts';
482
+
import { date } from'@clack/prompts';
483
483
484
-
constpicked=awaitdate({
485
-
message: 'Pick a date',
486
-
format: 'YMD',
487
-
minDate: newDate('2026-01-01'),
488
-
maxDate: newDate('2026-12-31'),
484
+
constbirthday=awaitdate({
485
+
message: 'Pick your birthday',
486
+
minDate: newDate('1900-01-01'),
487
+
initialValue: newDate(),
488
+
maxDate: newDate(),
489
489
});
490
-
491
-
if (isCancel(picked)) {
492
-
process.exit(0);
493
-
}
494
-
495
-
// picked is a Date
496
490
```
497
491
498
-
Options include `defaultValue`, `initialValue`, `minDate`, `maxDate`, `validate`, and the usual `signal`, `input`, `output`, and `withGuide` settings.
492
+
Options:
493
+
494
+
-`message`: The message or question shown to the user above the input.
495
+
-`format`: The date format to use (default: based on `locale`).
496
+
-`locale`: The [BCP 47 language tag](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag) to use for formatting.
497
+
-`defaultValue`: The default value returned when the user doesn't select a date.
498
+
-`initialValue`: The starting date shown when the prompt first renders. Users can edit this value before submitting.
499
+
-`minDate`: The minimum allowed date for validation.
500
+
-`maxDate`: The maximum allowed date for validation.
501
+
-`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..
502
+
- All [Common Options](#common-options)
499
503
500
504
### Confirmation
501
505
@@ -701,6 +705,10 @@ intro('Welcome to clack');
701
705
702
706
<preclass="cli-preview"><fontcolor="#555753">┌</font> Welcome to clack</pre>
703
707
708
+
Options:
709
+
710
+
- All [Common Options](#common-options)
711
+
704
712
### Outro
705
713
706
714
The `outro` function defines the end of an interaction.
@@ -716,20 +724,30 @@ outro('All operations are finished');
716
724
<fontcolor="#555753">└</font> All operations are finished
717
725
</pre>
718
726
727
+
Options:
728
+
729
+
- All [Common Options](#common-options)
730
+
719
731
### Cancel
720
732
721
733
The `cancel` function defines an interruption of an interaction and therefore its end.
722
734
It accepts an optional string parameter which is displayed as a cancellation message.
The `spinner` function provides a loading indicator for long-running operations.
@@ -1167,7 +1185,7 @@ await stream.step([
1167
1185
1168
1186
### limitOptions
1169
1187
1170
-
`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`.
1188
+
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.
0 commit comments