reflex-dev/reflex · error · ValueError
f"Match did not return a Var: {size_map_var}"
Error message
f"Match did not return a Var: {size_map_var}" What it means
When icon_button's `size` prop is a Var (not a static string), Reflex builds a Match expression to map Radix sizes to lucide pixel sizes. This internal sanity check fires if Match.create somehow returns a non-Var — practically only reachable through API misuse or version mismatch between reflex-components-radix and reflex core.
Source
Thrown at packages/reflex-components-radix/src/reflex_components_radix/themes/components/icon_button.py:88
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.
Returns:
The style of the component.
"""
return Style({"padding": "6px"})
icon_button = IconButton.create
View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Use a static size string: size='2'
- If dynamic sizing is needed, apply size via CSS class/cond instead of the size prop
- Re-sync workspace: uv sync to align reflex-core and reflex-components-radix versions, then retry; if it persists, report upstream
Example fix
# before
rx.icon_button('trash', size=State.size)
# after
rx.icon_button('trash', size='2') Defensive patterns
Strategy: validation
Validate before calling
# use static size when possible
rx.icon_button('trash', size='2') Prevention
- Keep reflex-core and reflex-components-radix versions in sync via uv sync
- Prefer static size strings
When it happens
Trigger: Passing size as a Var (e.g. size=State.icon_size) in an environment where the core Match API returns a non-Var, or after a partial/downgraded package upgrade.
Common situations: Mixed reflex package versions after a partial `uv sync`/pip install; using bleeding-edge Var types not handled by Match.create.
Related errors
- IconButton requires a child icon. Pass a string as the first
- Match children count mismatch: expected {num_cases + 1} (cas
- f"FormControl can only have at most one child, got {len(chil
- Only Radix TextFieldRoot and DebounceInput are allowed as ch
- f"The radio group component takes in a list, got {items_type
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/51a2ee510a21c5ed.
Report an issue: GitHub.