{"record":{"id":"02f673f42f3ff9d5","repo":"reflex-dev/reflex","slug":"must-provide-children-to-the-html-component","errorCode":null,"errorMessage":"Must provide children to the html component.","messagePattern":"Must provide children to the html component\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-core/src/reflex_components_core/core/html.py","lineNumber":35,"sourceCode":"\n    @classmethod\n    def create(cls, *children, **props):\n        \"\"\"Create a html component.\n\n        Args:\n            *children: The children of the component.\n            **props: The props to pass to the component.\n\n        Returns:\n            The html component.\n\n        Raises:\n            ValueError: If children are not provided or more than one child is provided.\n        \"\"\"\n        # If children are not provided, throw an error.\n        if len(children) != 1:\n            msg = \"Must provide children to the html component.\"\n            raise ValueError(msg)\n        props[\"dangerouslySetInnerHTML\"] = {\"__html\": children[0]}\n\n        # Apply the default classname\n        given_class_name = props.pop(\"class_name\", [])\n        if isinstance(given_class_name, str):\n            given_class_name = [given_class_name]\n        props[\"class_name\"] = [\"rx-Html\", *given_class_name]\n\n        # Create the component.\n        return super().create(**props)\n\n\nhtml = Html.create\n","sourceCodeStart":17,"sourceCodeEnd":49,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-core/src/reflex_components_core/core/html.py#L17-L49","documentation":"`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.","triggerScenarios":"`rx.html()` with no arguments; `rx.html('<b>a</b>', '<i>b</i>')`; passing children as separate positional args.","commonSituations":"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.","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"],"exampleFix":"// before\nrx.html('<b>hi</b>', '<i>bye</i>')\n// after\nrx.html('<b>hi</b><i>bye</i>')","handlingStrategy":"validation","validationCode":"html_str = ''.join(parts)\nnode = rx.html(html_str) if html_str else rx.fragment()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Join HTML fragments into one string before rx.html","Guard optional/empty HTML values with a fragment fallback"],"tags":["reflex","raw-html","component-children"],"backgroundTag":"invalid-children-count","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}