Skip to main content

Select

This prop is used to set the select of the component.

Structure

This prop has 4 required properties:

  • type - The namespace of the prop. \LivewirePageBuilder\Props\Select::class
  • label - The label of the prop. Select
  • default - The default value of the prop. ''
  • options - The options of the select. ['option1' => 'Option 1', 'option2' => 'Option 2', 'option3' => 'Option 3']

This prop has 1 optional property:

  • rules - The validation rules of the prop. ['nullable', 'string']

This prop will render a select input field in the editor.

Return value

The return value of the prop will be the key of the selected option.

Example

public static function getConfig(): array
{
return [
'name' => __('Custom Component'),
'description' => __('A custom component that can be used to display custom content.'),
'icon' => '/path/to/icon.svg',
'allow_children' => false,
'props' => [
'select' => [
'type' => \LivewirePageBuilder\Props\Select::class,
'label' => __('Select'),
'default' => '',
'options' => ['option1' => 'Option 1', 'option2' => 'Option 2', 'option3' => 'Option 3'],
'rules' => ['nullable', 'string'],
],
]
];
}