{"record":{"id":"6f55c5ecefd78a16","repo":"reflex-dev/reflex","slug":"iconbutton-requires-a-child-icon-pass-a-string-as","errorCode":null,"errorMessage":"IconButton requires a child icon. Pass a string as the first child or a rx.icon.","messagePattern":"IconButton requires a child icon\\. Pass a string as the first child or a rx\\.icon\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-radix/src/reflex_components_radix/themes/components/icon_button.py","lineNumber":76,"sourceCode":"            *children: The children of the component.\n            **props: The properties of the component.\n\n        Returns:\n            The IconButton component.\n\n        Raises:\n            ValueError: If no children are passed.\n        \"\"\"\n        if children:\n            if isinstance(children[0], str):\n                children = [\n                    Icon.create(\n                        children[0],\n                    )\n                ]\n        else:\n            msg = \"IconButton requires a child icon. Pass a string as the first child or a rx.icon.\"\n            raise ValueError(msg)\n        if \"size\" in props:\n            if isinstance(props[\"size\"], str):\n                children[0].size = RADIX_TO_LUCIDE_SIZE[props[\"size\"]]  # pyright: ignore[reportAttributeAccessIssue]\n            else:\n                size_map_var = Match.create(\n                    props[\"size\"],\n                    *list(RADIX_TO_LUCIDE_SIZE.items()),\n                    12,\n                )\n                if not isinstance(size_map_var, Var):\n                    msg = f\"Match did not return a Var: {size_map_var}\"\n                    raise ValueError(msg)\n                children[0].size = size_map_var  # pyright: ignore[reportAttributeAccessIssue]\n        return super().create(*children, **props)\n\n    def add_style(self):\n        \"\"\"Add style to the component.\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-radix/src/reflex_components_radix/themes/components/icon_button.py#L58-L94","documentation":"rx.icon_button (Radix theme) requires an icon: either a string icon name as the first child or an rx.icon component. Without it there is nothing to render inside the button, so ValueError is raised at creation time.","triggerScenarios":"rx.icon_button(on_click=...) with no children, or passing only keyword props.","commonSituations":"Refactoring that drops the icon argument; building buttons from a config dict where the icon key is missing.","solutions":["Pass a name: rx.icon_button('trash', on_click=State.delete)","Or a full icon component: rx.icon_button(rx.icon('trash', size=18))"],"exampleFix":"# before\nrx.icon_button(on_click=State.delete)\n# after\nrx.icon_button('trash', on_click=State.delete)","handlingStrategy":"validation","validationCode":"icon = cfg.get('icon') or 'circle'\nrx.icon_button(icon, on_click=handler)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default icon-button configs to a fallback icon name"],"tags":["reflex","radix","icon-button","missing-argument"],"backgroundTag":"missing-required-prop","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}