{"record":{"id":"98b93a2ec0a9f850","repo":"reflex-dev/reflex","slug":"alpha-must-be-a-boolean-or-a-var","errorCode":null,"errorMessage":"Alpha must be a boolean or a Var","messagePattern":"Alpha must be a boolean or a Var","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-core/src/reflex_components_core/core/colors.py","lineNumber":51,"sourceCode":"    if isinstance(color, str):\n        if color not in COLORS and REFLEX_VAR_OPENING_TAG not in color:\n            msg = f\"Color must be one of {COLORS}, received {color}\"\n            raise ValueError(msg)\n    elif not isinstance(color, Var):\n        msg = \"Color must be a string or a Var\"\n        raise ValueError(msg)\n\n    if isinstance(shade, int):\n        if shade < MIN_SHADE_VALUE or shade > MAX_SHADE_VALUE:\n            msg = f\"Shade must be between {MIN_SHADE_VALUE} and {MAX_SHADE_VALUE}\"\n            raise ValueError(msg)\n    elif not isinstance(shade, Var):\n        msg = \"Shade must be an integer or a Var\"\n        raise ValueError(msg)\n\n    if not isinstance(alpha, (bool, Var)):\n        msg = \"Alpha must be a boolean or a Var\"\n        raise ValueError(msg)\n\n    return Color(color, shade, alpha)\n","sourceCodeStart":33,"sourceCodeEnd":54,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-core/src/reflex_components_core/core/colors.py#L33-L54","documentation":"The `alpha` parameter of `rx.color()` must be a boolean or a Var. It toggles whether the returned color uses the alpha (opacity) variant of the theme color; numeric opacity values are not supported.","triggerScenarios":"`rx.color('red', 7, 0.5)`, `rx.color('red', 7, 1)`, or passing an alpha string 'true'.","commonSituations":"Assuming alpha is an opacity float like in CSS rgba(); migrating from styles that used opacity numbers.","solutions":["Pass True/False: rx.color('red', 7, True)","For fractional opacity, wrap the result: rx.box(opacity=0.5, background=rx.color('red', 7))","For dynamic alpha, pass a Var of bool type"],"exampleFix":"// before\nrx.color('red', 7, 0.5)\n// after\nrx.box(background=rx.color('red', 7), opacity=0.5)","handlingStrategy":"type-guard","validationCode":"alpha = bool(alpha) if not isinstance(alpha, Var) else alpha","typeGuard":"def is_valid_alpha(a) -> bool:\n    return isinstance(a, (bool, Var))","tryCatchPattern":null,"preventionTips":["Remember alpha is a boolean toggle, not an opacity float","Use the opacity prop for fractional transparency"],"tags":["reflex","color","type-error"],"backgroundTag":"invalid-argument-type","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}