Skip to content

Element class

The definition of a custom visual element.

An element is defined by its properties (name, type and default value) and what the default property name is.

Methods

__init__()

__init__(
    default_property: str,
    properties: t.Dict[str, ElementProperty],
    react_component: t.Optional[str] = None,
    render_xhtml: t.Optional[
        t.Callable[[t.Dict[str, t.Any]], str]
    ] = None,
    inner_properties: t.Optional[
        t.Dict[str, ElementProperty]
    ] = None,
) -> None

Initializes a new custom element declaration.

If render_xhtml is specified, then this is a static element, and react_component is ignored.

Parameters:

Name Type Description Default

default_property

str

The name of the default property for this element.

required

properties

Dict[str, ElementProperty]

The dictionary containing the properties of this element, where the keys are the property names and the values are instances of ElementProperty.

required

inner_properties

Optional[List[ElementProperty]]

The optional list of inner properties for this element.
Default values are set/binded automatically.

None

react_component

Optional[str]

The name of the component to be created on the front-end.
If not specified, it is set to a camel case version of the element's name ("one_name" is transformed to "OneName").

None

render_xhtml

Optional[callable[[dict[str, Any]], str]]

A function that receives a dictionary containing the element's properties and their values and that must return a valid XHTML string.

None