reflex-dev/reflex · error · TypeError
f"The radio group component takes in a list, got {items_type
Error message
f"The radio group component takes in a list, got {items_type} instead" What it means
rx.radio_group(items=...) requires items to be a Python list or a Var whose type is a list. Anything else (a string, tuple, set, dict, or a Var of a non-list type) raises TypeError because the component compiles the list into radio options.
Source
Thrown at packages/reflex-components-radix/src/reflex_components_radix/themes/components/radio_group.py:169
The created radio group component.
Raises:
TypeError: If the type of items is invalid.
"""
direction = props.pop("direction", "row")
spacing = props.pop("spacing", "2")
size = props.pop("size", "2")
variant = props.pop("variant", "classic")
color_scheme = props.pop("color_scheme", None)
default_value = props.pop("default_value", "")
if not isinstance(items, (list, Var)) or (
isinstance(items, Var)
and not types.typehint_issubclass(items._var_type, list)
):
items_type = type(items) if not isinstance(items, Var) else items._var_type
msg = f"The radio group component takes in a list, got {items_type} instead"
raise TypeError(msg)
default_value = LiteralVar.create(default_value)
# convert only non-strings to json(JSON.stringify) so quotes are not rendered
# for string literal types.
if isinstance(default_value, str) or (
isinstance(default_value, Var) and default_value._var_type is str
):
default_value = LiteralVar.create(default_value)
else:
default_value = LiteralVar.create(default_value).to_string()
def radio_group_item(value: Var) -> Component:
item_value = cond(
value.js_type() == "string",
value,
value.to_string(),
).to(StringVar)View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Pass a list literal: rx.radio_group(items=['a','b','c'])
- Type state fields as lists: options: list[str] = ['a','b']
- Convert tuples/sets: rx.radio_group(items=list(my_tuple))
Example fix
# before
rx.radio_group(items=('low','medium','high'))
# after
rx.radio_group(items=['low','medium','high']) Defensive patterns
Strategy: type-guard
Validate before calling
items = list(items) if isinstance(items, tuple) else items assert isinstance(items, list) or (isinstance(items, Var) and issubclass(items._var_type, list)) rx.radio_group(items=items)
Type guard
def valid_items(v) -> bool:
from reflex.vars import Var
return isinstance(v, list) or (isinstance(v, Var) and issubclass(v._var_type, list)) Prevention
- Normalize config options with list(...) before passing
- Type option state fields as list[str]
When it happens
Trigger: rx.radio_group(items='a,b,c'), items=('a','b') (tuple), items={'a','b'} (set), or items=State.names where names: str.
Common situations: Passing a comma-separated string from a config; storing options as a tuple/JSON string in state; forgetting to json.loads() API data before assignment.
Related errors
- Only Radix TextFieldRoot and DebounceInput are allowed as ch
- Invalid data type {type(data)} for download. Use `str` or `b
- Unsupported Operand type(s) for {operator}: {', '.join(t.__n
- Expected a mapping type or a dataclass, got {_var_value!r} o
- Color must be a string or a Var
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/d0fa95434f81a8ab.
Report an issue: GitHub.