How to create colored pills that span multiple lines? (multiline boxes)

Indeed that works well!

#let pill(a, b, fill: gray, radius: 100%) = {
  highlight(
    fill: fill, 
    stroke: fill, 
    radius: (left: radius),
    [#sym.zws~~~~~#sym.wj]
  )
  h(-.7em)
  highlight(
    fill: fill, 
    stroke: fill, 
    text(white, hyphenate: true, [#sym.wj#a~#sym.zws])
  )
  highlight(
    fill: none, 
    stroke: (y: fill), 
    text(hyphenate: true)[#sym.zws~#b#sym.wj]
  )
  h(-.7em)
  highlight(
    fill: none, 
    stroke: (y: fill, right: fill), 
    radius: (right: radius),
    text(fill, [#sym.wj~~~~~#sym.zws])
  )
}

#box(width: 9em)[
  #pill("definitely good even when")[it goes to new line!]
]

#box(width: 9em)[
  #pill("first")[line!]\
  #pill("second")[line! All good!]
  
  #pill("thirddddddddddddd")[line! All good!]
  #pill("fourth")[line! Also good!]
  #pill("fifthhhhhhhhhhhhhhh")[line! Indeed also good!]
]

Results in:

To me this is almost perfect!

3 Likes