reflex-dev/reflex · error · ValueError
IconButton requires a child icon. Pass a string as the…
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.
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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- f"Match did not return a Var
- f"FormControl can only have at most one child, got
- f"The radio group component takes in a list, got
- For conditional vars, the second argument must be set.
- For ` ` template, `template_code_dir_name` and…
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/6f55c5ecefd78a16.
Report an issue: GitHub.
Appendix: 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)