-
It is possible to write reference-able inline text spans / Markup links? I would like to have labeled inline text spans, like this in HTML: <span class='x'>x</span> = 1
<span class='z'>z</span> = <span class='x'>x</span> + <span class='y'>y</span> With behavior like Related resources:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
To the best of my knowledge there isn't a supported method of doing that. At the moment you could exploit a known bug where all links with the exact same action get the same styling when one of them receives hover, you can see this in action with this code: from random import choice
from string import ascii_uppercase
from textual.app import App, ComposeResult
from textual.widgets import Static
class HoverLettersApp(App[None]):
CSS = """
Static {
link-style: none;
link-color-hover: white;
link-background-hover: red;
}
"""
def compose(self) -> ComposeResult:
text = ""
for _ in range(5000):
letter = choice(ascii_uppercase)
text += f"[@click=does_nothing('{letter}')]{letter}[/]"
yield Static(text)
def action_does_nothing(self) -> None:
pass
if __name__ == "__main__":
HoverLettersApp().run() but this is seen as a bug (#1587) and will likely receive a fix one day. |
Beta Was this translation helpful? Give feedback.
-
Question to maintainers: given that markup links exist, how feasible would it be to make them reference-able (by an id or class)? Markup links fulfill many of the requirements in my question:
So making them reference-able seems like one solution approach. |
Beta Was this translation helpful? Give feedback.
To the best of my knowledge there isn't a supported method of doing that. At the moment you could exploit a known bug where all links with the exact same action get the same styling when one of them receives hover, you can see this in action with this code: