Skip to content

Select

Interface

export type ISelectTypeValue = string;
 
export interface ISelectField extends CommonField {
    type: 'select';
    options: {
        placeholder?: string;
        items: {
            label: string;
            value: string;
        }[];
    };
    private?: () => Promise<ISelectTypeValue>;
    render?: (v: ISelectTypeValue) => JSX.Element;
    validation?: Validation<ISelectTypeValue>;
}

Example

 {
  type: 'select',
  name: 'YOUR_PATH',
  options: {
    placeholder: 'Select a language',
    items: [
      { value: 'javascript', label: 'JavaScript' },
      { value: 'typescript', label: 'TypeScript' },
      { value: 'python', label: 'Python' }
    ]
  },
  validation: z.union([
    z.literal('javascript'),
    z.literal('typescript'),
    z.literal('python')
  ])
}