Textual CSS¶
Textual uses CSS to apply style to widgets. If you have any exposure to web development you will have encountered CSS, but don't worry if you haven't: this chapter will get you up to speed.
VSCode User?
The official Textual CSS extension adds syntax highlighting for both external files and inline CSS.
Stylesheets¶
CSS stands for Cascading Stylesheet. A stylesheet is a list of styles and rules about how those styles should be applied to a web page. In the case of Textual, the stylesheet applies styles to widgets, but otherwise it is the same idea.
Let's look at some Textual CSS.
This is an example of a CSS rule set. There may be many such sections in any given CSS file.
Let's break this CSS code down a bit.
The first line is a selector which tells Textual which widget(s) to modify. In the above example, the styles will be applied to a widget defined by the Python class Header.