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
| loop |`boolean`| no | Defaults to `true`. When set to `false`, the cursor will be constrained to the top and bottom of the choice list without looping. |
44
44
| required |`boolean`| no | When set to `true`, ensures at least one choice must be selected. |
45
45
| validate |`string\[\] => boolean \| string \| Promise<string \| boolean>`| no | On submit, validate the choices. When returning a string, it'll be used as the error message displayed to the user. Note: returning a rejected promise, we'll assume a code error happened and crash. |
46
+
| theme |[See Theming](#Theming)| no | Customize look of the prompt. |
46
47
47
48
The `Separator` object can be used to render non-selectable lines in the choice list. By default it'll render a line, but you can provide the text as argument (`new Separator('-- Dependencies --')`). This option is often used to add labels to groups within long list of options.
48
49
50
+
## Theming
51
+
52
+
You can theme a prompt by passing a `theme` object option. The theme object only need to includes the keys you wish to modify, we'll fallback on the defaults for the rest.
53
+
54
+
```ts
55
+
typeTheme= {
56
+
prefix:string;
57
+
spinner: {
58
+
interval:number;
59
+
frames:string[];
60
+
};
61
+
style: {
62
+
answer: (text:string) =>string;
63
+
message: (text:string) =>string;
64
+
error: (text:string) =>string;
65
+
defaultAnswer: (text:string) =>string;
66
+
help: (text:string) =>string;
67
+
highlight: (text:string) =>string;
68
+
key: (text:string) =>string;
69
+
disabledChoice: (text:string) =>string;
70
+
};
71
+
icon: {
72
+
checked:string;
73
+
unchecked:string;
74
+
cursor:string;
75
+
};
76
+
};
77
+
```
78
+
49
79
# License
50
80
51
81
Copyright (c) 2023 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))<br/>
| default |`boolean`| no | Default answer (true or false) |
29
+
| transformer |`(boolean) => string`| no | Transform the prompt printed message to a custom string |
30
+
| theme |[See Theming](#Theming)| no | Customize look of the prompt. |
31
+
32
+
## Theming
33
+
34
+
You can theme a prompt by passing a `theme` object option. The theme object only need to includes the keys you wish to modify, we'll fallback on the defaults for the rest.
Copy file name to clipboardexpand all lines: packages/editor/README.md
+21
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,27 @@ const answer = await editor({
29
29
| validate |`string => boolean \| string \| Promise<string \| boolean>`| no | On submit, validate the content. When returning a string, it'll be used as the error message displayed to the user. Note: returning a rejected promise, we'll assume a code error happened and crash. |
30
30
| postfix |`string`| no (default to `.txt`) | The postfix of the file being edited. Adding this will add color highlighting to the file content in most editors. |
31
31
| waitForUseInput |`boolean`| no (default to `true`) | Open the editor automatically without waiting for the user to press enter. Note that this mean the user will not see the question! So make sure you have a default value that provide guidance if it's unclear what input is expected. |
32
+
| theme |[See Theming](#Theming)| no | Customize look of the prompt. |
33
+
34
+
## Theming
35
+
36
+
You can theme a prompt by passing a `theme` object option. The theme object only need to includes the keys you wish to modify, we'll fallback on the defaults for the rest.
0 commit comments