Components
Components are interactive widgets that let users configure parameters (inputs) or view results inside your custom block.
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_tipcontrols the tooltip shown when hovering the component.fixed_width/fixed_heightare pixels. Use0for βautoβ.Some components override defaults (for example
DropDownis non-serializable;Imageis non-serializable by default).
Text Input
Allows users to input text/number through a single line.

Notes:
Use
check_type=intorcheck_type=floatto 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 List
Drop down lists allows users to choose an option from a provided list of texts.

Notes:
If you pass
itemsas adict[str, object], you can access the mapped value via.getCurrentMatch().
DropDown is currently marked as non-serializable. If you want the selection to persist in saved scenarios, store selected_index yourself (for example with register_ser_value() or serialize_node()).
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.

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?