{"record":{"id":"a84271d51c6262b0","repo":"reflex-dev/reflex","slug":"f-icon-name-must-be-a-string-got-children-0-va","errorCode":null,"errorMessage":"f\"Icon name must be a string, got {children[0]._var_type if isinstance(children[0], Var) else children[0]}\"","messagePattern":"f\"Icon name must be a string, got (.+?)\"","errorType":"validation","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-lucide/src/reflex_components_lucide/icon.py","lineNumber":55,"sourceCode":"        Run some additional checks on Icon component.\n\n        Args:\n            *children: The positional arguments\n            **props: The keyword arguments\n\n        Returns:\n            The created component.\n\n        Raises:\n            AttributeError: The errors tied to bad usage of the Icon component.\n            TypeError: If the icon name is not a string.\n        \"\"\"\n        if children:\n            if len(children) == 1:\n                child = Var.create(children[0]).guess_type()\n                if not isinstance(child, StringVar):\n                    msg = f\"Icon name must be a string, got {children[0]._var_type if isinstance(children[0], Var) else children[0]}\"\n                    raise AttributeError(msg)\n                props[\"tag\"] = children[0]\n            else:\n                msg = f\"Passing multiple children to Icon component is not allowed: remove positional arguments {children[1:]} to fix\"\n                raise AttributeError(msg)\n        if \"tag\" not in props:\n            msg = \"Missing 'tag' keyword-argument for Icon\"\n            raise AttributeError(msg)\n\n        tag_var: Var | LiteralVar = Var.create(props.pop(\"tag\"))\n        if isinstance(tag_var, LiteralVar):\n            if isinstance(tag_var, LiteralStringVar):\n                tag = format.to_snake_case(tag_var._var_value.lower())\n            else:\n                msg = f\"Icon name must be a string, got {type(tag_var)}\"\n                raise TypeError(msg)\n        elif isinstance(tag_var, Var):\n            tag_stringified = tag_var.guess_type()\n            if not isinstance(tag_stringified, StringVar):","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-lucide/src/reflex_components_lucide/icon.py#L37-L73","documentation":"rx.icon() (lucide) accepts a single icon name as its only child/positional argument, and that name must resolve to a string Var. If the value's inferred type is not a string (e.g. an int, bool, or object Var), Reflex raises AttributeError at component creation time because it cannot map the value to a lucide icon tag.","triggerScenarios":"rx.icon(123), rx.icon(State.count) where count is an int, or passing a component/object as the icon name.","commonSituations":"Passing a state variable holding an icon index or an enum/int instead of the icon name string; passing rx.text('home') as a child.","solutions":["Pass a string icon name: rx.icon('home')","If using state, ensure the Var is typed str: rx.icon(State.icon_name) where icon_name: str","For non-string data, convert before passing: rx.icon(str(State.value)) won't help for Vars — store the name as a str state field instead"],"exampleFix":"# before\nrx.icon(123)\n# after\nrx.icon('home')","handlingStrategy":"type-guard","validationCode":"name = 'home'\nassert isinstance(name, str), 'icon name must be a str'","typeGuard":"def is_icon_name(v) -> bool:\n    from reflex.vars import Var\n    return isinstance(v, str) or (isinstance(v, Var) and v._var_type is str)","tryCatchPattern":null,"preventionTips":["Keep icon names as strings in state and config","Type state fields used for icons as str"],"tags":["reflex","lucide","icon","type-error"],"backgroundTag":"component-child-type-mismatch","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}