You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: include a bordered, 'label'-ish style in standard style set #93
Essentially, I'd wish it were easier to draw a box around a phrase (like ggplot2::geom_label()).
Here is a style I'm proposing to include (perhaps a better name may be needed):
As an aside, I don't think the horizontal spacing between words with padding is in sync with where borders are drawn. This is noticible when the padding is exaggerated.
g<- marquee_grob(
"This is a {.button button} word",
x=0.5, y=0.5, hjust=0.5, width=NA,
style=style|>
modify_style("button", padding= trbl(10))
)
grid.newpage()
grid.draw(g)
I think this is a great idea. One thing to keep in mind, and why rendering this is non-trivial: The span that you want to enclose in a box can run over more than a single line. So then you need to think about drawing only the left part or only the right part of a box.
So if we linebreak in the middle of the box span, browsers will display a box without a right border on the top line, and a box without left border on the bottom line. This is the snippet I used in the widget Claus linked:
The quick brown fox jumps over the lazy dog.
<spanclass="box">The quick brown <br>
fox jumps over the lazy dog.</span>
The quick brown fox jumps over the lazy dog.
Which renders like so:
marquee_grob() just draws two full-bordered boxes around the two parts, which I think is fine too as marquee isn't aiming to be/implement html.
Details
library(marquee)
library(grid)
style<- classic_style() |>
modify_style(
"button",
border="black",
border_width= trbl(1),
border_radius= em(0.25),
padding= trbl(em(0.1))
)
g<- marquee_grob(
"The quick brown fox jumps over the lazy dog. {.button The quick brown \n fox jumps over the lazy dog.} The quick brown fox jumps over the lazy dog.",
x=0.5, y=0.5, hjust=0.5, width=NA,
style=style
)
grid.newpage()
grid.draw(g)
Activity
clauswilke commentedon Sep 26, 2025
I think this is a great idea. One thing to keep in mind, and why rendering this is non-trivial: The span that you want to enclose in a box can run over more than a single line. So then you need to think about drawing only the left part or only the right part of a box.
Here is a quick example of how web browsers handle this: https://jsfiddle.net/7dbeL30g/1
teunbrand commentedon Sep 26, 2025
So if we linebreak in the middle of the box span, browsers will display a box without a right border on the top line, and a box without left border on the bottom line. This is the snippet I used in the widget Claus linked:
Which renders like so:
marquee_grob()just draws two full-bordered boxes around the two parts, which I think is fine too as marquee isn't aiming to be/implement html.Details
Created on 2025-09-26 with reprex v2.1.1
clauswilke commentedon Sep 26, 2025
Oh, apologies, I misunderstood. I didn't realize marquee already can draw borders. Yes, I guess it's fine if it does it differently from HTML.
teunbrand commentedon Sep 26, 2025
This feature request is merely a suggestion to make borders more accessible.
Fix r-lib#93