Skip to content

Default value on Field #1073

Answered by Ambushfall
felipeRmBr asked this question in Q&A
Jan 29, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hello, the prop you're looking for is value.

Suggested Solution:

let [title] = await fields([
    {
        name: "title",
        label: "Title",
        type: "text",
        placeholder: "John",
        value: "My default title" // using the pre-set prop value satisfies your request
    }
])

Types and Interface for the fields method

export interface Fields {
  (fields: string[] | Field[]): Promise<any>
  (
    config: PromptConfig & { fields: string[] | Field[] }
  ): Promise<any>
}


type Field = {
  label?: string
  placeholder?: string
  value?: string
  type?: string
  [key: string]: string
}

export type PromptConfig = {
  validate?: (
    choice: string
  ) => boolean | string | P…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@felipeRmBr
Comment options

@Ambushfall
Comment options

Answer selected by felipeRmBr
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