mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
1.2 KiB
1.2 KiB
Hatch
The hatch style fills a widget's background with a repeating character for a pleasing textured effect.
Syntax
--8<-- "docs/snippets/syntax_block_start.md" hatch: (<hatch> | CHARACTER) <color> [<percentage>] --8<-- "docs/snippets/syntax_block_end.md"
The hatch type can be specified with a constant, or a string. For example, cross for cross hatch, or "T" for a custom character.
The color can be any Textual color value.
An optional percentage can be used to set the opacity.
Examples
An app to show a few hatch effects.
=== "Output"
```{.textual path="docs/examples/styles/hatch.py"}
```
=== "hatch.py"
```py
--8<-- "docs/examples/styles/hatch.py"
```
=== "hatch.tcss"
```css
--8<-- "docs/examples/styles/hatch.tcss"
```
CSS
/* Red cross hatch */
hatch: cross red;
/* Right diagonals, 50% transparent green. */
hatch: right green 50%;
/* T custom character in 80% blue. **/
hatch: "T" blue 80%;
Python
widget.styles.hatch = ("cross", "red")
widget.styles.hatch = ("right", "rgba(0,255,0,128)")
widget.styles.hatch = ("T", "blue")