···128128Grouping prompts together is a great way to keep your code organized. This accepts a JSON object with a name that can be used to reference the group later. The second argument is an optional but has a `onCancel` callback that will be called if the user cancels one of the prompts in the group.
129129130130```js
131131-import * as p from '@clack/prompts'
131131+import * as p from '@clack/prompts';
132132133133-const group = await p.group({
134134- name: () => p.text({ message: "What is your name?" }),
135135- age: () => p.text({ message: "What is your age?" }),
136136- color: ({ results }) => p.multiselect({
137137- message: `What is your favorite color ${results.name}?`,
138138- options: [
139139- { value: 'red', label: 'Red' },
140140- { value: 'green', label: 'Green' },
141141- { value: 'blue', label: 'Blue' },
142142- ],
143143- })
144144-},
145145-{
146146- // On Cancel callback that wraps the group
147147- // So if the user cancels one of the prompts in the group this function will be called
148148- onCancel: ({ results }) => {
149149- p.cancel('Operation cancelled.')
150150- process.exit(0)
133133+const group = await p.group(
134134+ {
135135+ name: () => p.text({ message: 'What is your name?' }),
136136+ age: () => p.text({ message: 'What is your age?' }),
137137+ color: ({ results }) =>
138138+ p.multiselect({
139139+ message: `What is your favorite color ${results.name}?`,
140140+ options: [
141141+ { value: 'red', label: 'Red' },
142142+ { value: 'green', label: 'Green' },
143143+ { value: 'blue', label: 'Blue' },
144144+ ],
145145+ }),
146146+ },
147147+ {
148148+ // On Cancel callback that wraps the group
149149+ // So if the user cancels one of the prompts in the group this function will be called
150150+ onCancel: ({ results }) => {
151151+ p.cancel('Operation cancelled.');
152152+ process.exit(0);
153153+ },
151154 }
152152-})
155155+);
153156154154-console.log(group.name, group.age, group.color)
157157+console.log(group.name, group.age, group.color);
155158```