Components

Components are interactive widgets that let users configure parameters (inputs) or view results inside your custom block.

circle-info

Components are constructed by keyword arguments.

Generic Arguments

Generic arguments apply to all custom components. You can provide them as keyword arguments to constructors.

Instead of repeating them under every component, here is a small β€œpyi-style” reference:

# Common keyword arguments (supported by all components)
class _CommonComponentKwargs:
    def __init__(
        self,
        *,
        tool_tip: str = "",
        enabled: bool = True,
        hidden: bool = False,
        fixed_width: int = 0,
        fixed_height: int = 0,
        minimum_width: int = 0,
        minimum_height: int = 0,
        maximum_width: int = 0,
        maximum_height: int = 0,
        serializable: bool = True,
        stylesheet: str = "",
        font_size: int = -1,
        font_bold: bool = False,
        alignment: str = "AlignLeft",
        **kwargs,
    ) -> None: ...

Notes:

  • tool_tip controls the tooltip shown when hovering the component.

  • fixed_width / fixed_height are pixels. Use 0 for β€œauto”.

  • Some components override defaults (for example DropDown is non-serializable; Image is non-serializable by default).

Text Input

Allows users to input text/number through a single line.

Notes:

  • Use check_type=int or check_type=float to restrict what the user can type.

  • Use .toInt() / .toFloat() when you want conversion errors to surface with a clear exception (no silent fallback).

Example:

Drop down lists allows users to choose an option from a provided list of texts.

Notes:

  • If you pass items as a dict[str, object], you can access the mapped value via .getCurrentMatch().

circle-exclamation

Example:

Label

Labels are simple text based components to statically or dynamically show text on your custom block.

They are also used to provide information about interactable components:

Example:

Slider

Restricts user input to range of numbers.

Example:

Slider Labeled

Same as Slider but adds a label that automatically shows which value is shown in component.

Example:

CheckBox

Allows logic state input.

Example:

Button

Triggers an event in your script on mouse click. This component is also very useful for resource management for custom blocks in your scenario.

circle-info

Use set_clicked_callback(...) inside init().

Example:

Example above utilizes callbacks using register_resource and get_resource.

Image

Example:

Table

Allows multiple items/modes to be selected at the same time.

Example:

Text Edit

Text Edit is a multi-line text area.

Example:

Last updated

Was this helpful?