reflex-dev/reflex · error · ValueError

Must provide children to the html component.

Error message

Must provide children to the html component.

What it means

`rx.html()` injects a single raw HTML string via dangerouslySetInnerHTML and therefore requires exactly one child. Zero children or multiple children (including a list) fail this check.

Source

Thrown at packages/reflex-components-core/src/reflex_components_core/core/html.py:35

    @classmethod
    def create(cls, *children, **props):
        """Create a html component.

        Args:
            *children: The children of the component.
            **props: The props to pass to the component.

        Returns:
            The html component.

        Raises:
            ValueError: If children are not provided or more than one child is provided.
        """
        # If children are not provided, throw an error.
        if len(children) != 1:
            msg = "Must provide children to the html component."
            raise ValueError(msg)
        props["dangerouslySetInnerHTML"] = {"__html": children[0]}

        # Apply the default classname
        given_class_name = props.pop("class_name", [])
        if isinstance(given_class_name, str):
            given_class_name = [given_class_name]
        props["class_name"] = ["rx-Html", *given_class_name]

        # Create the component.
        return super().create(**props)


html = Html.create

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Concatenate into one string: rx.html(html1 + html2)
  2. Guard empties: rx.html(html) if html else rx.fragment()
  3. Never pass components as children — only a raw HTML string

Example fix

// before
rx.html('<b>hi</b>', '<i>bye</i>')
// after
rx.html('<b>hi</b><i>bye</i>')
Defensive patterns

Strategy: validation

Validate before calling

html_str = ''.join(parts)
node = rx.html(html_str) if html_str else rx.fragment()

Prevention

When it happens

Trigger: `rx.html()` with no arguments; `rx.html('<b>a</b>', '<i>b</i>')`; passing children as separate positional args.

Common situations: Concatenation mistakes where HTML fragments are passed as two args instead of one string; building html() from an optional value that can be empty/None.

Related errors


AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28). Data as JSON: /api/errors/02f673f42f3ff9d5. Report an issue: GitHub.