Files
textual/docs/styles/color.md
Will McGugan 33dc6acad0 Update docs/styles/color.md
Co-authored-by: darrenburns <darrenburns@users.noreply.github.com>
2022-08-05 09:15:06 +01:00

593 B

Color

The color rule sets the text color of a Widget.

=== "color.py"

```python
--8<-- "docs/examples/styles/color.py"
```

=== "Output"

```{.textual path="docs/examples/styles/color.py"}
```

CSS

/* Blue text */
color: blue;

/* 20% red text */
color: red 20%;

/* RGB color */
color: rgb(100,120,200);

Python

You can use the same syntax as CSS, or explicitly set a Color object.

# Set blue text
widget.styles.color = "blue"

from textual.color import Color
# Set with a color object
widget.styles.color = Color.parse("pink")