{"record":{"id":"d0fa95434f81a8ab","repo":"reflex-dev/reflex","slug":"f-the-radio-group-component-takes-in-a-list-got","errorCode":null,"errorMessage":"f\"The radio group component takes in a list, got {items_type} instead\"","messagePattern":"f\"The radio group component takes in a list, got (.+?) instead\"","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-radix/src/reflex_components_radix/themes/components/radio_group.py","lineNumber":169,"sourceCode":"            The created radio group component.\n\n        Raises:\n            TypeError: If the type of items is invalid.\n        \"\"\"\n        direction = props.pop(\"direction\", \"row\")\n        spacing = props.pop(\"spacing\", \"2\")\n        size = props.pop(\"size\", \"2\")\n        variant = props.pop(\"variant\", \"classic\")\n        color_scheme = props.pop(\"color_scheme\", None)\n        default_value = props.pop(\"default_value\", \"\")\n\n        if not isinstance(items, (list, Var)) or (\n            isinstance(items, Var)\n            and not types.typehint_issubclass(items._var_type, list)\n        ):\n            items_type = type(items) if not isinstance(items, Var) else items._var_type\n            msg = f\"The radio group component takes in a list, got {items_type} instead\"\n            raise TypeError(msg)\n\n        default_value = LiteralVar.create(default_value)\n\n        # convert only non-strings to json(JSON.stringify) so quotes are not rendered\n        # for string literal types.\n        if isinstance(default_value, str) or (\n            isinstance(default_value, Var) and default_value._var_type is str\n        ):\n            default_value = LiteralVar.create(default_value)\n        else:\n            default_value = LiteralVar.create(default_value).to_string()\n\n        def radio_group_item(value: Var) -> Component:\n            item_value = cond(\n                value.js_type() == \"string\",\n                value,\n                value.to_string(),\n            ).to(StringVar)","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-radix/src/reflex_components_radix/themes/components/radio_group.py#L151-L187","documentation":"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.","triggerScenarios":"rx.radio_group(items='a,b,c'), items=('a','b') (tuple), items={'a','b'} (set), or items=State.names where names: str.","commonSituations":"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.","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))"],"exampleFix":"# before\nrx.radio_group(items=('low','medium','high'))\n# after\nrx.radio_group(items=['low','medium','high'])","handlingStrategy":"type-guard","validationCode":"items = list(items) if isinstance(items, tuple) else items\nassert isinstance(items, list) or (isinstance(items, Var) and issubclass(items._var_type, list))\nrx.radio_group(items=items)","typeGuard":"def valid_items(v) -> bool:\n    from reflex.vars import Var\n    return isinstance(v, list) or (isinstance(v, Var) and issubclass(v._var_type, list))","tryCatchPattern":null,"preventionTips":["Normalize config options with list(...) before passing","Type option state fields as list[str]"],"tags":["reflex","radix","radio-group","type-error"],"backgroundTag":"component-prop-validation","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}