Skip to content


The text-style rule enables a number of different ways of displaying text.

Text styles may be set in combination. For example bold underline or reverse underline strike.


text-style: <TEXT STYLE> ...;


Value Description
bold bold text
italic italic text
reverse reverse video text (foreground and background colors reversed)
underline underline text
strike strikethrough text


Each of the three text panels has a different text style.

from import App
from textual.widgets import Static

TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where the fear has gone there will be nothing. Only I will remain."""

class TextStyleApp(App):
    def compose(self):
        yield Static(TEXT, id="static1")
        yield Static(TEXT, id="static2")
        yield Static(TEXT, id="static3")

app = TextStyleApp(css_path="text_style.css")
Screen {
    layout: horizontal;    
Static {
#static1 {
    background: red 30%;
    text-style: bold;
#static2 {
    background: green 30%;
    text-style: italic;
#static3 {
    background: blue 30%;
    text-style: reverse;

TextStyleApp I must not fear.I must not fear.I must not fear. Fear is the mind-killer.Fear is the mind-killer.Fear is the mind-killer. Fear is the little-death Fear is the little-death Fear is the little-death  that brings total that brings total that brings total  obliteration.obliteration.obliteration. I will face my fear.I will face my fear.I will face my fear. I will permit it to pass I will permit it to pass I will permit it to pass  over me and through me.over me and through me.over me and through me. And when it has gone past,And when it has gone past, And when it has gone past,  I will turn the inner eye I will turn the inner eye I will turn the inner eye  to see its see its see its path. Where the fear has gone Where the fear has gone Where the fear has gone  there will be nothing. there will be nothing. Onlythere will be nothing. Only Only I will remain.I will remain.I will remain.


text-style: italic;


widget.styles.text_style = "italic"