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
- Concatenate into one string: rx.html(html1 + html2)
- Guard empties: rx.html(html) if html else rx.fragment()
- 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
- Join HTML fragments into one string before rx.html
- Guard optional/empty HTML values with a fragment fallback
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
- Provide a single child for DebounceInput, such as rx.input()
- ChildrenTypeError(component=cls.__name__, child=child)
- Do not override _add_style directly. Use add_style instead.
- The component `{comp_name}` cannot have `{child_name}` as a
- The component `{comp_name}` only allows the components: {val
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/02f673f42f3ff9d5.
Report an issue: GitHub.