Skip to content

Form

endstone.form

Classes:

Name Description
ActionForm

Represents a form with buttons that let the player take action.

Dropdown

Represents a dropdown with a set of predefined options.

Label

Represents a text label.

MessageForm

Represents a form with two buttons.

ModalForm

Represents a modal form with controls.

Slider

Represents a slider with a label.

StepSlider

Represents a step slider with a set of predefined options.

TextInput

Represents a text input field.

Toggle

Represents a toggle button with a label.

ActionForm

ActionForm(
    title: str | Translatable = "",
    content: str | Translatable = "",
    buttons: list[Button] | None = None,
    on_submit: Callable[[Player, int], None] = None,
    on_close: Callable[[Player], None] = None,
)

Represents a form with buttons that let the player take action.

Classes:

Name Description
Button

Represents a button with text and an optional icon.

Methods:

Name Description
add_button

Adds a button to the form.

Attributes:

Name Type Description
buttons list[Button]

Gets or sets the buttons of the action form.

content str | Translatable

Gets or sets the content of the form.

on_close Callable[[Player], None]

Gets or sets the on close callback.

on_submit Callable[[Player, int], None]

Gets or sets the on submit callback.

title str | Translatable

Gets or sets the title of the form.

buttons property writable

buttons: list[Button]

Gets or sets the buttons of the action form.

content property writable

content: str | Translatable

Gets or sets the content of the form.

on_close property writable

on_close: Callable[[Player], None]

Gets or sets the on close callback.

on_submit property writable

on_submit: Callable[[Player, int], None]

Gets or sets the on submit callback.

title property writable

title: str | Translatable

Gets or sets the title of the form.

Button

Button(
    text: str | Translatable = "",
    icon: str | None = None,
    on_click: Callable[[Player], None] = None,
)

Represents a button with text and an optional icon.

Attributes:

Name Type Description
icon str | None

Gets or sets the icon path or URL of the button

on_click Callable[[Player], None]

Gets or sets the on click callback.

text str | Translatable

Gets or sets the text of the button

icon property writable
icon: str | None

Gets or sets the icon path or URL of the button

on_click property writable
on_click: Callable[[Player], None]

Gets or sets the on click callback.

text property writable
text: str | Translatable

Gets or sets the text of the button

add_button

add_button(
    text: str | Translatable,
    icon: str | None = None,
    on_click: Callable[[Player], None] = None,
) -> ActionForm

Adds a button to the form.

Dropdown

Dropdown(
    label: str | Translatable = "",
    options: list[str] | None = None,
    default_index: int | None = None,
)

Represents a dropdown with a set of predefined options.

Methods:

Name Description
add_option

Adds a new option to the dropdown.

Attributes:

Name Type Description
default_index int | None

Gets or sets the optional default index of the dropdown.

label str | Translatable

Gets or sets the label of the dropdown.

options list[str]

Gets or sets the options of the dropdown.

default_index property writable

default_index: int | None

Gets or sets the optional default index of the dropdown.

label property writable

label: str | Translatable

Gets or sets the label of the dropdown.

options property writable

options: list[str]

Gets or sets the options of the dropdown.

add_option

add_option(option: str) -> Dropdown

Adds a new option to the dropdown.

Label

Label(text: str | Translatable = '')

Represents a text label.

Attributes:

Name Type Description
text str | Translatable

Gets or sets the text of the label.

text property writable

text: str | Translatable

Gets or sets the text of the label.

MessageForm

MessageForm(
    title: str | Translatable = "",
    content: str | Translatable = "",
    button1: str | Translatable = "",
    button2: str | Translatable = "",
    on_submit: Callable[[Player, int], None] = None,
    on_close: Callable[[Player], None] = None,
)

Represents a form with two buttons.

Attributes:

Name Type Description
button1 str | Translatable

Gets or sets the text of button1.

button2 str | Translatable

Gets or sets the text of button2.

content str | Translatable

Gets or sets the content of the form.

on_close Callable[[Player], None]

Gets or sets the on close callback.

on_submit Callable[[Player, int], None]

Gets or sets the on submit callback.

title str | Translatable

Gets or sets the title of the form.

button1 property writable

button1: str | Translatable

Gets or sets the text of button1.

button2 property writable

button2: str | Translatable

Gets or sets the text of button2.

content property writable

content: str | Translatable

Gets or sets the content of the form.

on_close property writable

on_close: Callable[[Player], None]

Gets or sets the on close callback.

on_submit property writable

on_submit: Callable[[Player, int], None]

Gets or sets the on submit callback.

title property writable

title: str | Translatable

Gets or sets the title of the form.

ModalForm

ModalForm(
    title: str | Translatable = "",
    controls: (
        list[
            Dropdown
            | Label
            | Slider
            | StepSlider
            | TextInput
            | Toggle
        ]
        | None
    ) = None,
    submit_button: str | Translatable | None = None,
    icon: str | None = None,
    on_submit: Callable[[Player, str], None] = None,
    on_close: Callable[[Player], None] = None,
)

Represents a modal form with controls.

Methods:

Name Description
add_control

Adds a control to the form.

Attributes:

Name Type Description
controls list[Dropdown | Label | Slider | StepSlider | TextInput | Toggle]

Gets or sets the controls of the modal form.

icon str | None

Gets or sets the icon of the form.

on_close Callable[[Player], None]

Gets or sets the on close callback.

on_submit Callable[[Player, str], None]

Gets or sets the on submit callback.

submit_button str | Translatable | None

Gets or sets the submit button message of the form.

title str | Translatable

Gets or sets the title of the form.

controls property writable

Gets or sets the controls of the modal form.

icon property writable

icon: str | None

Gets or sets the icon of the form.

on_close property writable

on_close: Callable[[Player], None]

Gets or sets the on close callback.

on_submit property writable

on_submit: Callable[[Player, str], None]

Gets or sets the on submit callback.

submit_button property writable

submit_button: str | Translatable | None

Gets or sets the submit button message of the form.

title property writable

title: str | Translatable

Gets or sets the title of the form.

add_control

add_control(
    control: (
        Dropdown
        | Label
        | Slider
        | StepSlider
        | TextInput
        | Toggle
    ),
) -> ModalForm

Adds a control to the form.

Slider

Slider(
    label: str | Translatable = "",
    min: float = 0,
    max: float = 100,
    step: float = 20,
    default_value: float | None = None,
)

Represents a slider with a label.

Attributes:

Name Type Description
default_value float | None

Gets or sets the optional default value of the slider.

label str | Translatable

Gets or sets the label of the slider.

max float

Gets or sets the maximum value of the slider.

min float

Gets or sets the minimum value of the slider.

step float

Gets or sets the step size of the slider.

default_value property writable

default_value: float | None

Gets or sets the optional default value of the slider.

label property writable

label: str | Translatable

Gets or sets the label of the slider.

max property writable

max: float

Gets or sets the maximum value of the slider.

min property writable

min: float

Gets or sets the minimum value of the slider.

step property writable

step: float

Gets or sets the step size of the slider.

StepSlider

StepSlider(
    label: str | Translatable = "",
    options: list[str] | None = None,
    default_index: int | None = None,
)

Represents a step slider with a set of predefined options.

Methods:

Name Description
add_option

Adds a new option to the step slider.

Attributes:

Name Type Description
default_index int | None

Gets or sets the optional default index of the step slider.

label str | Translatable

Gets or sets the label of the step slider.

options list[str]

Gets or sets the options of the step slider.

default_index property writable

default_index: int | None

Gets or sets the optional default index of the step slider.

label property writable

label: str | Translatable

Gets or sets the label of the step slider.

options property writable

options: list[str]

Gets or sets the options of the step slider.

add_option

add_option(option: str) -> Dropdown

Adds a new option to the step slider.

TextInput

TextInput(
    label: str | Translatable = "",
    placeholder: str | Translatable = "",
    default_value: str | None = None,
)

Represents a text input field.

Attributes:

Name Type Description
default_value str | None

Gets or sets the optional default text of the text input field.

label str | Translatable

Gets or sets the label of the text input field.

placeholder str | Translatable

Gets or sets the placeholder of the text input field.

default_value property writable

default_value: str | None

Gets or sets the optional default text of the text input field.

label property writable

label: str | Translatable

Gets or sets the label of the text input field.

placeholder property writable

placeholder: str | Translatable

Gets or sets the placeholder of the text input field.

Toggle

Toggle(
    label: str | Translatable = "",
    default_value: bool = False,
)

Represents a toggle button with a label.

Attributes:

Name Type Description
default_value bool

Gets or sets the value of the toggle.

label str | Translatable

Gets or sets the label of the toggle.

default_value property writable

default_value: bool

Gets or sets the value of the toggle.

label property writable

label: str | Translatable

Gets or sets the label of the toggle.