{"record":{"id":"30e9b51e88926f2b","repo":"reflex-dev/reflex","slug":"title-must-be-a-single-string","errorCode":null,"errorMessage":"Title must be a single string.","messagePattern":"Title must be a single string\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-core/src/reflex_components_core/base/meta.py","lineNumber":30,"sourceCode":")  # for compatibility\n\n\nclass Title(elements.Title):\n    \"\"\"A component that displays the title of the current page.\"\"\"\n\n    def render(self) -> dict:\n        \"\"\"Render the title component.\n\n        Returns:\n            The rendered title component.\n\n        Raises:\n            ValueError: If the title is not a single string.\n        \"\"\"\n        # Make sure the title is a single string.\n        if len(self.children) != 1 or not isinstance(self.children[0], Bare):\n            msg = \"Title must be a single string.\"\n            raise ValueError(msg)\n        return super().render()\n\n\nclass Description(elements.Meta):\n    \"\"\"A component that displays the title of the current page.\"\"\"\n\n    name: Var[str] = field(\n        default=Var.create(\"description\"), doc=\"The type of the description.\"\n    )\n\n\nclass Image(elements.Meta):\n    \"\"\"A component that displays the title of the current page.\"\"\"\n\n    property: Var[str] = field(\n        default=Var.create(\"og:image\"), doc=\"The type of the image.\"\n    )\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-core/src/reflex_components_core/base/meta.py#L12-L48","documentation":"The document Title (rx.metadata.title / Title.create) must render exactly one bare string; Reflex enforces a single text child because HTML <title> cannot contain elements or multiple text nodes produced by fragments.","triggerScenarios":"Calling Title.create with no children, multiple children, or a non-Bare child such as a Var, component, or concatenated expression, then calling render().","commonSituations":"Passing a State Var (Title.create(State.title)) or an f-string with Vars; adding multiple strings as separate children; forgetting the child entirely.","solutions":["Pass a single Python string literal: rx.title('My Page')","For dynamic titles, set them via State side effects or rx.App(title=...) rather than embedding a Var","Ensure only one child is provided"],"exampleFix":"// before\nrx.title(State.page_title)\n\n// after\nrx.title(\"My Page\")  # static; update dynamically via state","handlingStrategy":"validation","validationCode":"title = \"My Page\"\nassert isinstance(title, str)","typeGuard":"def is_valid_title(children) -> bool:\n    return len(children) == 1 and isinstance(children[0], str)","tryCatchPattern":null,"preventionTips":["Pass one plain string to rx.title","Set dynamic titles through app config or state, not Var children"],"tags":["metadata","title","children-validation"],"backgroundTag":"component-children-validation","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}