Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Inactive group headers for GroupMultiSelectPrompt #199

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AdrianGonz97
Copy link

@AdrianGonz97 AdrianGonz97 commented Jun 20, 2024

Closes #197

By default, group headers are selectable, allowing you to quickly select all of the options within that group. Setting the new option, selectableGroups, to false will disable them, making the group headers inactive.

the following code snippet:

import { groupMultiselect } from "@clack/prompts";

await groupMultiselect({
	message: "Which libraries would you like to setup?",
	selectableGroups: false,
	cursorAt: "Bootstrap",
	options: {
		CSS: [
			{ label: "Bootstrap", value: "Bootstrap" },
			{ label: "TailwindCSS", value: "TailwindCSS" },
			{ label: "UnoCSS", value: "UnoCSS" },
			{ label: "Bulma", value: "Bulma" },
		],
		Testing: [
			{ label: "Playwright", value: "Playwright" },
			{ label: "Vitest", value: "Vitest" },
		],
		Database: [
			{ label: "Drizzle", value: "Drizzle" },
			{ label: "Prisma", value: "Prisma" },
		],
		Auth: [
			{ label: "Lucia", value: "Lucia" },
			{ label: "Auth.js", value: "Auth.js" },
		],
	},
});

will now produce this prompt:
img

Vertical spacing can also be adjusted with a spacedGroups option as well:
img

@Mist3rBru
Copy link
Contributor

Hey @AdrianGonz97, great work!

I just wanted to point out that the first group shouldn't have an empty line before it. In my opinion, this option should only add empty lines between the groups, not before or after. It looks a bit odd compared to the other prompts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] header component or multiselect with multiple groups
3 participants