{"record":{"id":"6b53beba8294f487","repo":"Textualize/textual","slug":"invalid-value-for-display-received-new-val-r-e","errorCode":null,"errorMessage":"invalid value for display (received {new_val!r}, expected {friendly_list(VALID_DISPLAY)})","messagePattern":"invalid value for display \\(received (.+?), expected (.+?)\\)","errorType":"validation","errorClass":"StyleValueError","httpStatus":null,"severity":"error","filePath":"src/textual/dom.py","lineNumber":933,"sourceCode":"        )\n\n    @display.setter\n    def display(self, new_val: bool | str) -> None:\n        \"\"\"\n        Args:\n            new_val: Shortcut to set the ``display`` CSS property.\n                ``False`` will set ``display: none``. ``True`` will set ``display: block``.\n                A ``False`` value will prevent the DOMNode from consuming space in the layout.\n        \"\"\"\n        # TODO: This will forget what the original \"display\" value was, so if a user\n        #  toggles to False then True, we'll reset to the default \"block\", rather than\n        #  what the user initially specified.\n        if isinstance(new_val, bool):\n            self.styles.display = \"block\" if new_val else \"none\"\n        elif new_val in VALID_DISPLAY:\n            self.styles.display = new_val\n        else:\n            raise StyleValueError(\n                f\"invalid value for display (received {new_val!r}, \"\n                f\"expected {friendly_list(VALID_DISPLAY)})\",\n            )\n\n    @property\n    def visible(self) -> bool:\n        \"\"\"Is this widget visible in the DOM?\n\n        If a widget hasn't had its visibility set explicitly, then it inherits it from its\n        DOM ancestors.\n\n        This may be set explicitly to override inherited values.\n        The valid values include the valid values for the `visibility` rule and the booleans\n        `True` or `False`, to set the widget to be visible or invisible, respectively.\n\n        When a node is invisible, Textual will reserve space for it, but won't display anything.\n        \"\"\"\n        own_value = self.styles.get_rule(\"visibility\")","sourceCodeStart":915,"sourceCodeEnd":951,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/dom.py#L915-L951","documentation":"The display setter accepts booleans or one of the valid CSS display keywords; anything else raises StyleValueError. Valid values come from VALID_DISPLAY (e.g. 'block', 'none').","triggerScenarios":"Assigning widget.display = 'inline-block' or another unsupported keyword, or a non-str/non-bool value like an int or None.","commonSituations":"Assuming full CSS display support (textual supports only a subset); passing a computed value that can be None or 0; version differences where supported display values changed.","solutions":["Use a boolean (True -> 'block', False -> 'none') or one of the documented VALID_DISPLAY strings","Check VALID_DISPLAY from textual.css.constants before assigning dynamic values","Use widget.styles.display only with supported keywords, or hide/show via widget.visible for visibility semantics"],"exampleFix":"# before\nwidget.display = 'inline-block'  # StyleValueError\n\n# after\nwidget.display = False  # or 'none' / 'block'","handlingStrategy":"type-guard","validationCode":"from textual.css.constants import VALID_DISPLAY\n\ndef set_display(widget, value):\n    if isinstance(value, bool) or value in VALID_DISPLAY:\n        widget.display = value\n    else:\n        raise ValueError(f'unsupported display {value!r}')","typeGuard":"from textual.css.constants import VALID_DISPLAY\ndef is_valid_display(v) -> bool:\n    return isinstance(v, bool) or (isinstance(v, str) and v in VALID_DISPLAY)","tryCatchPattern":"from textual.css.styles import StylesError  # StyleValueError base\ntry:\n    widget.display = value\nexcept StylesError:\n    widget.display = 'block'  # safe fallback","preventionTips":["Stick to True/False or 'block'/'none'","Validate config-driven style strings against VALID_DISPLAY","Remember textual supports a CSS subset, not full CSS"],"tags":["textual","display","styles","validation"],"backgroundTag":"invalid-css-style-value","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}