A sortable checkbox prompt for Inquirer.js that maintains the order of selection. Perfect for prioritizing tasks, ranking options, or creating ordered lists.
- β Multi-select with ordering: Select multiple options while preserving selection order
- π’ Visual order indicators: See the selection order with numbered badges
- β¨οΈ Keyboard navigation: Full keyboard support for accessibility
- π¨ Customizable themes: Style the prompt to match your application
- π¦ TypeScript support: Full type definitions included
- π Modern ESM: Built with modern JavaScript modules
npm install @kyou-izumi/inquirer-ordered-checkbox
import orderedCheckbox from '@kyou-izumi/inquirer-ordered-checkbox';
const answer = await orderedCheckbox({
message: 'Select your priorities in order:',
choices: [
'Complete project documentation',
'Fix critical bugs',
'Implement new features',
'Code review',
'Write tests'
]
});
console.log('Your priorities:', answer);
// Output: ['Fix critical bugs', 'Complete project documentation', 'Write tests']
import orderedCheckbox, { Separator } from '@kyou-izumi/inquirer-ordered-checkbox';
const answer = await orderedCheckbox({
message: 'Configure your development workflow:',
choices: [
{
name: 'Set up CI/CD pipeline',
value: 'cicd',
description: 'Automated testing and deployment'
},
{
name: 'Code quality tools',
value: 'quality',
description: 'Linting, formatting, and analysis'
},
{
name: 'Documentation',
value: 'docs',
description: 'API docs and user guides'
},
{
name: 'Performance monitoring',
value: 'monitoring',
description: 'Track app performance and errors'
},
{
name: 'Legacy system',
value: 'legacy',
disabled: true // Cannot be selected
}
],
default: ['quality', 'docs'], // Pre-select in this order
validate: (choices) => {
if (choices.length === 0) {
return 'Please select at least one option.';
}
if (choices.length > 3) {
return 'Please select no more than 3 options.';
}
return true;
}
});
import orderedCheckbox, { Separator } from '@kyou-izumi/inquirer-ordered-checkbox';
const answer = await orderedCheckbox({
message: 'Choose your tech stack:',
choices: [
'Frontend Frameworks',
new Separator(),
'React',
'Vue.js',
'Angular',
new Separator(),
'Backend Technologies',
new Separator(),
'Node.js',
'Python',
'Go'
]
});
Option | Type | Default | Description |
---|---|---|---|
message |
string |
The question to ask the user | |
choices |
Array<Choice | Separator | string> |
List of choices | |
default |
Array<Value> |
[] |
Pre-selected values in order |
validate |
function |
Validation function for the answer | |
theme |
object |
Custom theme configuration | |
pageSize |
number |
7 |
Number of choices to display per page |
interface Choice<T = any> {
name?: string; // Display name (defaults to value)
value: T; // The actual value returned
description?: string; // Help text shown on selection
short?: string; // Abbreviated name for final answer
disabled?: boolean; // Cannot be selected
}
type ValidateFunction<T> = (
choices: T[]
) => boolean | string | Promise<boolean | string>;
Return true
for valid input, or a string error message for invalid input.
Key | Action |
---|---|
β/β |
Navigate up/down |
Space |
Toggle selection |
Enter |
Submit answer |
? |
Toggle help |
Customize the appearance with a theme object:
const customTheme = {
icon: {
cursor: 'β―',
},
style: {
disabledChoice: (text) => `π« ${text}`,
description: (text) => `π‘ ${text}`,
selectedOrder: (text) => `π₯ ${text}`,
unselectedOrder: (text) => `β ${text}`,
renderSelectedChoices: (choices) =>
choices.map(c => `β¨ ${c.name}`).join(', ')
}
};
const answer = await orderedCheckbox({
message: 'Select items:',
choices: ['Option 1', 'Option 2', 'Option 3'],
theme: customTheme
});
This package includes full TypeScript definitions:
import orderedCheckbox, {
CheckboxSortConfig,
NormalizedChoice,
CheckboxSortTheme
} from '@kyou-izumi/inquirer-ordered-checkbox';
interface MyValue {
id: string;
priority: number;
}
const config: CheckboxSortConfig<MyValue> = {
message: 'Select tasks:',
choices: [
{
name: 'High priority task',
value: { id: 'task1', priority: 1 }
},
{
name: 'Medium priority task',
value: { id: 'task2', priority: 2 }
}
]
};
const result: MyValue[] = await orderedCheckbox(config);
- Node.js >= 18
- ESM environment (import/export)
- Inquirer.js - A collection of common interactive command line user interfaces
- @inquirer/prompts - Individual prompt packages
Contributions are welcome! Please feel free to submit a Pull Request.
Copyright Β© 2025 Kyou Izumi Licensed under the MIT license.