Textualize/textual · error · StyleValueError
unknown word {word!r} in style flags
Error message
unknown word {word!r} in style flags What it means
StyleFlagsProperty (used by rules like `text-style`) validates each whitespace-separated word against VALID_STYLE_FLAGS before delegating to rich's Style.parse. Unknown words — including misspelled flags or non-Textual web CSS keywords — raise StyleValueError naming the word.
Source
Thrown at src/textual/css/_style_properties.py:1094
style_flags: The style flags to set as a string. For example,
``"bold italic"``.
Raises:
StyleValueError: If the value is an invalid style flag.
"""
_rich_traceback_omit = True
if style_flags is None:
if obj.clear_rule(self.name):
obj.refresh(children=True)
elif isinstance(style_flags, Style):
if obj.set_rule(self.name, style_flags):
obj.refresh(children=True)
else:
words = [word.strip() for word in style_flags.split(" ")]
valid_word = VALID_STYLE_FLAGS.__contains__
for word in words:
if not valid_word(word):
raise StyleValueError(
f"unknown word {word!r} in style flags",
help_text=style_flags_property_help_text(
self.name, word, context="inline"
),
)
try:
style = Style.parse(style_flags)
except rich.errors.StyleSyntaxError as error:
if "none" in words and len(words) > 1:
raise StyleValueError(
"cannot mix 'none' with other style flags",
help_text=style_flags_property_help_text(
self.name, " ".join(words), context="inline"
),
) from None
raise error from None
if obj.set_rule(self.name, style):
obj.refresh(children=True)View on GitHub (pinned to 06dbeef4bb)
Solutions
- Use only documented style flags, separated by spaces
- Check the VALID_STYLE_FLAGS set for your installed version if unsure
Example fix
# before styles.text_style = "bold ittalic" # after styles.text_style = "bold italic"
Defensive patterns
Strategy: validation
Validate before calling
from textual.css.constants import VALID_STYLE_FLAGS
words = value.split()
if all(w in VALID_STYLE_FLAGS for w in words):
styles.text_style = value Prevention
- Filter user-supplied style-flag words against VALID_STYLE_FLAGS before joining
When it happens
Trigger: `styles.text_style = "bold ittalic"`, `styles.text_style = "underline2"` (if unsupported in that version), or `text-style: strike;` in TCSS. Valid flags include bold, italic, underline, reverse, none, etc.
Common situations: Typos, mixing in rich-only or web-CSS keywords, or flags removed/renamed across Textual versions.
Related errors
- {self.name} must be one of {friendly_list(self._valid_values
- cannot mix 'none' with other style flags
- Expected a str, Path or list[str | Path] for the CSS_PATH.
- {self.name} must be a str
- invalid percentage value '{token}'
AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27).
Data as JSON: /api/errors/53177a0fea169a8c.
Report an issue: GitHub.