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

  1. Use a static size string: size='2'
  2. If dynamic sizing is needed, apply size via CSS class/cond instead of the size prop
  3. 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

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


AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28). Data as JSON: /api/errors/51a2ee510a21c5ed. Report an issue: GitHub.