Files
textual/docs/styles/links/index.md
2023-12-20 17:11:30 +00:00

3.0 KiB

Links

Textual supports the concept of inline "links" embedded in text which trigger an action when pressed. There are a number of styles which influence the appearance of these links within a widget.

!!! note

These CSS rules only target Textual action links. Internet hyperlinks are not affected by these styles.
Property Description
link-background The background color of the link text.
link-background-hover The background color of the link text when the cursor is over it.
link-color The color of the link text.
link-color-hover The color of the link text when the cursor is over it.
link-style The style of the link text (e.g. underline).
link-style-hover The style of the link text when the cursor is over it.

Syntax

--8<-- "docs/snippets/syntax_block_start.md" link-background: <color> [<percentage>];

link-color: <color> [<percentage>];

link-style: <text-style>;

link-background-hover: <color> [<percentage>];

link-color-hover: <color> [<percentage>];

link-style-hover: <text-style>; --8<-- "docs/snippets/syntax_block_end.md"

Visit each style's reference page to learn more about how the values are used.

Example

In the example below, the first label illustrates default link styling. The second label uses CSS to customize the link color, background, and style.

=== "Output"

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

=== "links.py"

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

=== "links.tcss"

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

Additional Notes

  • Inline links are not widgets, and thus cannot be focused.

See Also