--- title: Options --- The Forge library extends the [Zod](https://github.com/colinhacks/zod) library. This means that you can use any Zod schema to validate the data that you want to store for your block. The Forge extends the zod schemas with the `layout` function property that allows you to define the layout of the data in the Typebot editor. Options extends the `z.ZodObject` schema. The Forge provide convenient functions to create the options schema for you. Even though you could provide straight Zod schemas, we highly recommend using `option` functions to create the options schema. Here is an example of how a schema can be created using the `option` and `layout` functions: ```ts option.object({ token: option.string.layout({ label: 'Token', isRequired: true, placeholder: 'Type your token...', helperText: 'You can find your token [here](https://).', }), role: option.enum(['user', 'admin']).layout({ defaultValue: 'user', label: 'Role', }), phoneNumber: option.string.layout({ accordion: 'Advanced settings', label: 'Phone number', placeholder: 'Type your phone number...', }), address: option.string.layout({ accordion: 'Advanced settings', label: 'Address', placeholder: 'Type your address...', }), isTestModeEnabled: option.boolean.layout({ label: 'Test mode', defaultValue: true, helperText: 'Enable test mode to use a test account.', }), }) ``` Layout label ## Object ```ts option.object({ //... }) ``` ## String Example: ```ts option.string.layout({ label: 'Name', placeholder: 'Type a name...', withVariableButton: false, }) ``` Layout string example ## Number Example: ```ts option.number.layout({ label: 'Temperature', defaultValue: 1, direction: 'row', }) ``` Layout number example ## Boolean ```ts option.boolean.layout({ label: 'Test mode', moreInfoTooltip: 'Enable test mode to use a test account.', }) ``` {' '} Layout boolean example ## Enum Example: ```ts option.enum(['user', 'admin']).layout({ label: 'Role', defaultValue: 'user', }) ``` Layout enum example ## Discriminated unions Example: ```ts option.discriminatedUnion('type', [ option.object({ type: option.literal('user'), name: option.string.layout({ placeholder: 'Type a name...' }), }), option.object({ type: option.literal('admin'), name: option.string.layout({ placeholder: 'Type a name...' }), phoneNumber: option.string.layout({ placeholder: 'Type a phone number...', }), }), ]) ``` Layout discriminated union example ## Literal Used mainly for [discriminated unions](./options#discriminated-unions). It is not visible on the Typebot editor. Example: ```ts option.literal('user') ``` ## Array Use this to collect a list of values. Example: - A list of names ```ts option.array(option.string.layout({ placeholder: 'Type a name...' })).layout({ label: 'Names', itemLabel: 'name', }) ``` Layout array example ## Helpers ### Save Response Array Use this to save the response of an array of options in variables. For example if you want your user to be able to save the response of an HTTP request to variables: ```ts option.saveResponseArray(['Message content', 'Total tokens']).layout({ accordion: 'Save response', }) ``` You provide the list of all the possible response values to save. Layout save response array example ## Layout props The label of the option. Will often be displayed right above the input. The placeholder of the input. The helper text of the input. Will often be displayed below the input. The name of the accordion where the option will be displayed in. For example if you'd like to group 2 properties in the same accordion named "Advanced settings", you can write: ```ts option.object({ temperature: option.number.layout({ accordion: 'Advanced settings', }), humidity: option.number.layout({ accordion: 'Advanced settings', }), }) ``` The direction of the input. If set to `row`, the label will be displayed on the left of the input. The default value of the input. The tooltip that will be displayed when the user hovers the info icon of the input. Whether or not to display the variable button next to the input. The type of the input to display. Whether or not the input is required. Will display a red star next to the label if set to `true`. Set this if you'd like your input to provide a dropdown of dynamically fetched items. ```ts option.string.layout({ fetcher: 'fetchModels', }) ``` `fetchModels` should match the `id` of the fetcher that you defined in the `fetchers` prop of the action. See [Fetcher](./fetcher) for more information. ### Array only The label of the items of an array option. Will be displayed next to the "Add" label of the add button. Whether or not the order of the items in an array schema matters. Will display "plus" buttons above and below when hovering on an item.