reflex-dev/reflex · error · AttributeError
Missing 'tag' keyword-argument for Icon
Error message
Missing 'tag' keyword-argument for Icon
What it means
The lucide Icon component requires an icon name, either as the single positional child or the `tag` keyword argument. Without it there is no SVG to render, so Reflex raises AttributeError at creation time rather than silently rendering nothing.
Source
Thrown at packages/reflex-components-lucide/src/reflex_components_lucide/icon.py:62
The created component.
Raises:
AttributeError: The errors tied to bad usage of the Icon component.
TypeError: If the icon name is not a string.
"""
if children:
if len(children) == 1:
child = Var.create(children[0]).guess_type()
if not isinstance(child, StringVar):
msg = f"Icon name must be a string, got {children[0]._var_type if isinstance(children[0], Var) else children[0]}"
raise AttributeError(msg)
props["tag"] = children[0]
else:
msg = f"Passing multiple children to Icon component is not allowed: remove positional arguments {children[1:]} to fix"
raise AttributeError(msg)
if "tag" not in props:
msg = "Missing 'tag' keyword-argument for Icon"
raise AttributeError(msg)
tag_var: Var | LiteralVar = Var.create(props.pop("tag"))
if isinstance(tag_var, LiteralVar):
if isinstance(tag_var, LiteralStringVar):
tag = format.to_snake_case(tag_var._var_value.lower())
else:
msg = f"Icon name must be a string, got {type(tag_var)}"
raise TypeError(msg)
elif isinstance(tag_var, Var):
tag_stringified = tag_var.guess_type()
if not isinstance(tag_stringified, StringVar):
msg = f"Icon name must be a string, got {tag_var._var_type}"
raise TypeError(msg)
return DynamicIcon.create(name=tag_stringified.replace("_", "-"), **props)
if tag not in LUCIDE_ICON_LIST:
icons_sorted = sorted(
LUCIDE_ICON_LIST,View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Pass the name positionally: rx.icon('home')
- Or pass it explicitly: rx.icon(tag='home')
Example fix
# before
rx.icon(size=20)
# after
rx.icon('home', size=20) Defensive patterns
Strategy: validation
Validate before calling
assert icon_name, 'icon name required'
Prevention
- Always include the icon name when building icon props dynamically
When it happens
Trigger: rx.icon() with no arguments, or rx.icon(size=20, color='red') with only keyword props and no name.
Common situations: Building icon props dynamically and accidentally dropping the name; refactoring that renames `tag` to something else.
Related errors
- f"Icon name must be a string, got {children[0]._var_type if
- f"Passing multiple children to Icon component is not allowed
- f"Icon name must be a string, got {type(tag_var)}"
- f"Icon name must be a string, got {tag_var._var_type}"
- For conditional vars, the second argument must be set.
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/d77fc24bcef794cb.
Report an issue: GitHub.