reflex-dev/reflex · error · ValueError
IconButton requires a child icon. Pass a string as the first
Error message
IconButton requires a child icon. Pass a string as the first child or a rx.icon.
What it means
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.
Source
Thrown at packages/reflex-components-radix/src/reflex_components_radix/themes/components/icon_button.py:76
*children: The children of the component.
**props: The properties of the component.
Returns:
The IconButton component.
Raises:
ValueError: If no children are passed.
"""
if children:
if isinstance(children[0], str):
children = [
Icon.create(
children[0],
)
]
else:
msg = "IconButton requires a child icon. Pass a string as the first child or a rx.icon."
raise ValueError(msg)
if "size" in props:
if isinstance(props["size"], str):
children[0].size = RADIX_TO_LUCIDE_SIZE[props["size"]] # pyright: ignore[reportAttributeAccessIssue]
else:
size_map_var = Match.create(
props["size"],
*list(RADIX_TO_LUCIDE_SIZE.items()),
12,
)
if not isinstance(size_map_var, Var):
msg = f"Match did not return a Var: {size_map_var}"
raise ValueError(msg)
children[0].size = size_map_var # pyright: ignore[reportAttributeAccessIssue]
return super().create(*children, **props)
def add_style(self):
"""Add style to the component.
View on GitHub (pinned to 45b8ed5ab7)
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))
Example fix
# before
rx.icon_button(on_click=State.delete)
# after
rx.icon_button('trash', on_click=State.delete) Defensive patterns
Strategy: validation
Validate before calling
icon = cfg.get('icon') or 'circle'
rx.icon_button(icon, on_click=handler) Prevention
- Default icon-button configs to a fallback icon name
When it happens
Trigger: rx.icon_button(on_click=...) with no children, or passing only keyword props.
Common situations: Refactoring that drops the icon argument; building buttons from a config dict where the icon key is missing.
Related errors
- f"Match did not return a Var: {size_map_var}"
- For conditional vars, the second argument must be set.
- Missing 'tag' keyword-argument for Icon
- f"FormControl can only have at most one child, got {len(chil
- Only Radix TextFieldRoot and DebounceInput are allowed as ch
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/6f55c5ecefd78a16.
Report an issue: GitHub.