{"record":{"id":"7bb4214df862bae1","repo":"reflex-dev/reflex","slug":"f-invalid-variant-variant-available-variants","errorCode":null,"errorMessage":"f\"Invalid variant: {variant}. Available variants: {available_variants}\"","messagePattern":"f\"Invalid variant: (.+?)\\. Available variants: (.+?)\"","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-internal/src/reflex_components_internal/components/base/button.py","lineNumber":122,"sourceCode":"\n        if isinstance(loading, Var):\n            props[\"disabled\"] = cond(loading, True, disabled)\n            children_list.insert(0, cond(loading, spinner()))\n        else:\n            props[\"disabled\"] = True if loading else disabled\n            children_list.insert(0, spinner()) if loading else None\n\n        return super().create(*children_list, **props)\n\n    @staticmethod\n    def validate_variant(variant: LiteralButtonVariant):\n        \"\"\"Validate the button variant.\"\"\"\n        if variant not in BUTTON_VARIANTS[\"variant\"]:\n            available_variants = \", \".join(BUTTON_VARIANTS[\"variant\"].keys())\n            message = (\n                f\"Invalid variant: {variant}. Available variants: {available_variants}\"\n            )\n            raise ValueError(message)\n\n    @staticmethod\n    def validate_size(size: LiteralButtonSize):\n        \"\"\"Validate the button size.\"\"\"\n        if size not in BUTTON_VARIANTS[\"size\"]:\n            available_sizes = \", \".join(BUTTON_VARIANTS[\"size\"].keys())\n            message = f\"Invalid size: {size}. Available sizes: {available_sizes}\"\n            raise ValueError(message)\n\n    def _exclude_props(self) -> list[str]:\n        return [\n            *super()._exclude_props(),\n            \"size\",\n            \"variant\",\n            \"loading\",\n        ]\n\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-internal/src/reflex_components_internal/components/base/button.py#L104-L140","documentation":"The internal Button component validates its variant against the allowed variants (e.g. classic, solid, soft, surface, outline, ghost). An unknown variant string raises this.","triggerScenarios":"rx.button(\"Hi\", variant=\"primary\") — 'primary' is not in BUTTON_VARIANTS; typos or theme keys from other UI libraries (chakra-era names) trigger it.","commonSituations":"Migrating old Reflex (Chakra) code using variant=\"solid\"/\"primary\" or \"link\" to the new internal components; passing a dynamically-built variant string with a bad value.","solutions":["Use one of the listed variants in the error message, e.g. variant=\"solid\" or \"soft\"","If the value is dynamic, constrain it to the Literal type (rx.button variants) so your type checker catches it","For legacy Chakra variants, map them during migration (primary→solid, link→ghost)"],"exampleFix":"# before\nrx.button(\"Hi\", variant=\"primary\")\n# after\nrx.button(\"Hi\", variant=\"solid\")","handlingStrategy":"type-guard","validationCode":"ALLOWED = {'classic', 'solid', 'soft', 'surface', 'outline', 'ghost'}\nif variant not in ALLOWED:\n    variant = 'solid'  # or log & fall back","typeGuard":"def is_valid_button_variant(v: str) -> TypeGuard[str]:\n    from reflex_components_internal.components.base.button import BUTTON_VARIANTS\n    return v in BUTTON_VARIANTS['variant']","tryCatchPattern":null,"preventionTips":["Use the Literal variant type from the package for static checking","Map legacy Chakra variants during migration (primary→solid)"],"tags":["reflex","button","variant"],"backgroundTag":"invalid-enum-value","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}