{"record":{"id":"4c4350649db69acf","repo":"Textualize/textual","slug":"theme-r-is-not-a-builtin-theme-or-it-has-not-be","errorCode":null,"errorMessage":"{theme!r} is not a builtin theme, or it has not been registered. To use a custom theme, register it first using `register_theme`, then switch to that theme by setting the `TextArea.theme` attribute.","messagePattern":"(.+?) is not a builtin theme, or it has not been registered\\. To use a custom theme, register it first using `register_theme`, then switch to that theme by setting the `TextArea\\.theme` attribute\\.","errorType":"exception","errorClass":"ThemeDoesNotExist","httpStatus":null,"severity":"error","filePath":"src/textual/widgets/_text_area.py","lineNumber":1014,"sourceCode":"\n    def _watch_theme(self, theme: str) -> None:\n        \"\"\"We set the styles on this widget when the theme changes, to ensure that\n        if padding is applied, the colors match.\"\"\"\n        self._set_theme(theme)\n\n    def _app_theme_changed(self) -> None:\n        self._set_theme(self._theme.name)\n\n    def _set_theme(self, theme: str) -> None:\n        theme_object: TextAreaTheme | None\n\n        # If the user supplied a string theme name, find it and apply it.\n        try:\n            theme_object = self._themes[theme]\n        except KeyError:\n            theme_object = TextAreaTheme.get_builtin_theme(theme)\n            if theme_object is None:\n                raise ThemeDoesNotExist(\n                    f\"{theme!r} is not a builtin theme, or it has not been registered. \"\n                    f\"To use a custom theme, register it first using `register_theme`, \"\n                    f\"then switch to that theme by setting the `TextArea.theme` attribute.\"\n                ) from None\n\n        self._theme = dataclasses.replace(theme_object)\n        if theme_object:\n            base_style = theme_object.base_style\n            if base_style:\n                color = base_style.color\n                background = base_style.bgcolor\n                if color:\n                    self.styles.color = Color.from_rich_color(color)\n                if background:\n                    self.styles.background = Color.from_rich_color(background)\n            else:\n                # When the theme doesn't define a base style (e.g. the `css` theme),\n                # the TextArea background/color should fallback to its CSS colors.","sourceCodeStart":996,"sourceCodeEnd":1032,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/widgets/_text_area.py#L996-L1032","documentation":"Raised by TextArea._set_theme when the requested theme is neither in TextArea's registered themes dict nor among TextAreaTheme.get_builtin_theme() results. It suggests registering custom themes via register_theme before assigning TextArea.theme.","triggerScenarios":"text_area.theme = 'my-theme' without calling TextArea.register_theme(theme) first; misspelling a builtin name like 'drakula' instead of 'dracula'.","commonSituations":"Creating custom syntax themes, typos in builtin names, or assuming a theme from another Textual API (app themes) applies to TextArea.","solutions":["Register first: build a TextAreaTheme and call TextArea.register_theme(theme), then set text_area.theme = theme.name.","For builtin themes, use the exact name from TextAreaTheme builtin themes (e.g. 'css', 'dracula', 'vscode_dark', 'monokai').","Check for typos/case in the theme name."],"exampleFix":"# before\ntext_area.theme = 'my-theme'  # not registered\n# after\nfrom textual.widgets.text_area import TextAreaTheme, TextArea\nTextArea.register_theme(TextAreaTheme(name='my-theme', ...))\ntext_area.theme = 'my-theme'","handlingStrategy":"validation","validationCode":"from textual.widgets.text_area import TextAreaTheme\nif theme_name not in text_area._themes and TextAreaTheme.get_builtin_theme(theme_name) is None:\n    TextArea.register_theme(my_theme)","typeGuard":null,"tryCatchPattern":"from textual.widgets.text_area import ThemeDoesNotExist\ntry:\n    text_area.theme = name\nexcept ThemeDoesNotExist:\n    text_area.theme = 'css'  # fallback","preventionTips":["Call TextArea.register_theme before assigning custom themes","Use exact builtin theme names"],"tags":["textarea","theme","textual","registration"],"backgroundTag":"theme-not-found","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}