@minecraft/server-ui
    Preparing search index...

    Class CustomForm

    A customizable data driven (DDUI) form that lets you add buttons, labels, toggles, dropdowns, sliders, text fields, and more. The form layout is built by calling methods to add components before calling show(). Any Observable values bound to form components will automatically update the UI when their values change.

    Index

    Constructors

    Methods

    • Returns void

      Closes the form if it is currently being shown to the player. Throws a FormVisibilityError if the form is not currently open.

      This function can't be called in restricted-execution mode.

      This function can throw errors.

      minecraftcommon.EngineError

      FormVisibilityError

      minecraftserver.InvalidEntityError

    • Returns CustomForm

      Adds a close button to the form at the bottom and as an 'X' in the corner. Returns the form instance to allow method chaining.

      This function can't be called in restricted-execution mode.

      This function can throw errors.

      InvalidFormModificationError

    • Parameters

      • Optionaloptions: DividerOptions

        Optional configuration for the divider, such as visibility.

      Returns CustomForm

      Adds a horizontal divider line to the form layout. Useful for visually separating sections of the form. Returns the form instance to allow method chaining.

      This function can't be called in restricted-execution mode.

      This function can throw errors.

      InvalidFormModificationError

    • Returns boolean

      Returns true if the form is currently being shown to the player, false otherwise.

      This function can't be called in restricted-execution mode.

    • Returns Promise<DataDrivenScreenClosedReason>

      Shows the form to the player. Returns a promise that resolves with a DataDrivenScreenClosedReason indicating how the form was closed.

      This function can't be called in restricted-execution mode.

      This function can throw errors.

      minecraftcommon.EngineError

      FormVisibilityError

      minecraftserver.InvalidEntityError

    • Parameters

      • Optionaloptions: SpacingOptions

        Optional configuration for the spacer, such as visibility.

      Returns CustomForm

      Adds a vertical spacer component to the form layout. Useful for adding empty space between form components. Returns the form instance to allow method chaining.

      This function can't be called in restricted-execution mode.

      This function can throw errors.

      InvalidFormModificationError