Skip to content

Is there any way I can focus on a choice to begin with #1312

Closed Answered by johnlindquist
alkene0005 asked this question in Q&A
Discussion options

You must be logged in to vote

@alkene0005

Yes, you can set a defaultChoiceId in the prompt config:

let choices = ["John", "Mindy", "Ben"].map(name => {
  return {
    id: uuid(),
    name,
    value: name,
  }
})

let defaultChoiceId = choices.find(choice => choice.name === "Mindy")?.id

await arg(
  {
    placeholder: "Pick one",
    defaultChoiceId,
  },
  choices
)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alkene0005
Comment options

Answer selected by alkene0005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants