FORM ELEMENTS

Buttons

The button is a section, the code inside of which will be executed when you click on it.
After clicking on the button, the form will be automatically closed (a feature of Bedrock forms).

Can only be used in Modal form and Simple form because these forms support button interactions.
Using buttons in other forms may result in unexpected behavior or errors.
The button with the image can only be used in Simple form

form(-| )button ((with (name|title))|named) %string% [with image %string%]
command /modalform:
  trigger:
    create modal form named "Modal form":
      form button named "My button":
        broadcast "Pressed button"

    open last created form to player

Description of Modal form.

The Modal form allows you to specify or retrieve a text description that provides context or instructions to the user.
This description can be set during the creation of the form or modified later in an already created form.
It is particularly useful for guiding users through the form’s purpose or actions they need to take.
For more details, refer to the creation section Modal form .

form['s] content
content of form
%form%['s] content
content of %form%
command /modalform:
  trigger:
    create modal form named "Modal form":
      set content of form to "Sample text"
    open last created form to player

Custom form Elements

The values of Custom form Elements can only be retrieved in the run on form result section after the form is closed.

User Input element

Creates an element in which the user can enter any text.
Allows you to specify the initial text inside the field, and the placeholder text.

form(-| )input (with name|named) [%string% (with|and) [placeholder] %string%[(, | (with|and) ) [def[ault] [value]] %string%]]
Choosing from the list

Creates an element in which the user can select one of the suggested values. Allows you to specify the initial value by index.

form(-| )drop[(-| )]down (with name|named) %string% (with|and) [elements] %strings%[(, | (with|and) ) [def[ault] [(element [index]|index)]] %number%]
Label, note, text

Creates an element with text.

form(-| )label [(with (name|title)|named)] %string%
A slider with a numeric value selection

Creates an element in the form of a strip with a control in which the user can specify a value. Allows you to specify the minimum and maximum threshold of numbers, the initial value and the slider step.

form(-| )slider (with name|named) %string% [[(with|and) [min[imum] [value]] %number%[(, | (with|and) ) [max[imum] [value]] %number%[(, | (with|and) ) [def[ault] [value]] %number%[(, | (with|and) ) [[step] [value]] %number%]]]]
A slider with a selection of values

Creates an element similar to the numeric slider, but with text values. Allows you to specify the initial value by index.

form(-| )(text|step)[(-| )]slider (with name|named) %string% (with|and) [elements] %strings%[(, | (with|and) ) [def[ault] [(element [index]|index)]] %number%]
command /textsliderform:
    trigger:
        create custom form named "Text Slider Form":
          form textslider named "Choose an option" with elements "Option 1", "Option 2", "Option 3", "Option 4" with default element index 2

        open last created form to player
The switch element.

It has only two states, on or off.
You can specify the initial state.

form(-| )toggle (with name|named) %string% [(with|and) [def[ault]] [value] %boolean%]