Skip to content

FR: list item previews #1898

@dotcarmen

Description

@dotcarmen

somewhat related to #77

I'd like to show previews of items when using select. for example:

import { select } from '@inquirer/prompts';

const items: { [name: string]: string } = {
  foo: `This is a foo item.`
  bar: `This is
a
multiline
bar item.
`,
}

const selection = await select({
  message: `Please select an item`,
  choices: Object.keys(items),
  getPreview(item) {
    assert(item in items);
    return items[item];
  },
});

Might render as:

? Please select an item
  foo                       | This is 
❯ bar                       | a
                            | multiline
                            | bar item.

I'm not sure how the spacing would work out, but i'm sure theming can be used to influence how the preview is shown

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions