File: keyline.md

package info (click to toggle)
textual 2.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,084 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (83 lines) | stat: -rw-r--r-- 1,834 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Keyline

The `keyline` style is applied to a container and will draw lines around child widgets.

A keyline is superficially like the [border](./border.md) rule, but rather than draw inside the widget, a keyline is drawn outside of the widget's border. Additionally, unlike `border`, keylines can overlap and cross to create dividing lines between widgets.

Because keylines are drawn in the widget's margin, you will need to apply the [margin](./margin.md) or [grid-gutter](./grid/grid_gutter.md) rule to see the effect.


## Syntax

--8<-- "docs/snippets/syntax_block_start.md"
keyline: [<a href="../../css_types/keyline">&lt;keyline&gt;</a>] [<a href="../../css_types/color">&lt;color&gt;</a>];
--8<-- "docs/snippets/syntax_block_end.md"


## Examples

### Horizontal Keyline

The following examples shows a simple horizontal layout with a thin keyline.

=== "Output"

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

=== "keyline.py"

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

=== "keyline.tcss"

    ```css
    --8<-- "docs/examples/styles/keyline_horizontal.tcss"
    ```



### Grid keyline

The following examples shows a grid layout with a *heavy* keyline.

=== "Output"

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

=== "keyline.py"

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

=== "keyline.tcss"

    ```css 
    --8<-- "docs/examples/styles/keyline.tcss"
    ```


## CSS

```css
/* Set a thin green keyline */
/* Note: Must be set on a container or a widget with a layout. */
keyline: thin green;
```

## Python

You can set a keyline in Python with a tuple of type and color:

```python
widget.styles.keyline = ("thin", "green")
```


## See also

 - [`border`](./border.md) to add a border around a widget.