A Typst package for creating colorful and customizable boxes
Typst
149
132 commits
updated Jul 28, 2025
Showybox is a Typst package for creating colorful and customizable boxes.
Please note that this repository contains the latest (development) version of this package and may not yet be published at Typst's official package repository. If you want to use this package, see https://github.com/typst/packages/tree/main/packages/preview for the latest stable version
To use this library through the Typst package manager (for Typst 0.6.0 or greater), write #import "@preview/showybox:2.0.4": showybox at the beginning of your Typst file.
Once imported, you can create an empty showybox by using the function showybox() and giving a default body content inside the parenthesis or outside them using squared brackets [].
By default a showybox with these properties will be created:
5pt of border radius1pt of border thickness#import "@preview/showybox:2.0.4": showybox
#showybox(
[Hello world!]
)
Looks quite simple, but the "magic" starts when adding a title, color and shadows. The following code creates two "unique" boxes with defined colors and custom borders:
// First showybox
#showybox(
frame: (
border-color: red.darken(50%),
title-color: red.lighten(60%),
body-color: red.lighten(80%)
),
title-style: (
color: black,
weight: "regular",
align: center
),
shadow: (
offset: 3pt,
),
title: "Red-ish showybox with separated sections!",
lorem(20),
lorem(12)
)
// Second showybox
#showybox(
frame: (
dash: "dashed",
border-color: red.darken(40%)
),
body-style: (
align: center
),
sep: (
dash: "dashed"
),
shadow: (
offset: (x: 2pt, y: 3pt),
color: yellow.lighten(70%)
),
[This is an important message!],
[Be careful outside. There are dangerous bananas!]
)
The showybox() function can receive the following parameters:
title: A string used as the title of the showyboxfooter: A string used as the footer of the showyboxframe: A dictionary containing the frame's propertiestitle-style: A dictionary containing the title's stylesbody-style: A dictionary containing the body's stylesfooter-style: A dictionary containing the footer's stylessep: A dictionary containing the separator's propertiesshadow: A dictionary containing the shadow's propertieswidth: A relative length indicating the showybox's widthalign: An unidimensional alignment for the showybox in the pagebreakable: A boolean indicating whether a showybox can break if it reached an end of pagespacing: Space above and below the showyboxabove: Space above the showyboxbelow: Space below the showyboxbody: The content of the showyboxtitle-color: Color used as background color where the title goes (default is black)body-color: Color used as background color where the body goes (default is white)footer-color: Color used as background color where the footer goes (default is luma(85))border-color: Color used for the showybox's border (default is black)inset: Inset used for title, body and footer elements (default is (x: 1em, y: 0.65em)) if none of the followings are given:
title-inset: Inset used for the titlebody-inset: Inset used for the bodyfooter-inset: Inset used for the bodyradius: Showybox's radius (default is 5pt)thickness: Border thickness of the showybox (default is 1pt)dash: Showybox's border style (default is solid)color: Text color (default is white)weight: Text weight (default is bold)align: Text align (default is start)sep-thickness: Thickness of the separator between title and body (default is 1pt)boxed-style: If it's a dictionary of properties, indicates that the title must appear like a "floating box" above the showybox. If it's none, the title appears normally (default is none)anchor: Anchor of the boxed title
y: Vertical anchor (top, horizon or bottom -- default is horizon)x: Horizontal anchor (left, start, center, right, end -- default is start)offset: How much to offset the boxed title in x and y direction as a dictionary with keys x and y (default is 0pt)radius: Boxed title radius as a dictionary or relative length (default is 5pt)color: Text color (default is black)align: Text align (default is start)color: Text color (default is luma(85))weight: Text weight (default is regular)align: Text align (default is start)sep-thickness: Thickness of the separator between body and footer (default is 1pt)thickness: Separator's thickness (default is 1pt)dash: Separator's style (as a line dash style, default is "solid")gutter: Separator's space above and below (default is 0.65em)color: Shadow color (default is black)offset: How much to offset the shadow in x and y direction either as a length or a dictionary with keys x and y (default is 4pt)
Special thanks to enklht (https://github.com/enklht) and PgBiel (https://github.com/PgBiel) for their collaboration with this version's changes
start, instead of leftcounter inside a showybox declarationanchor inside a figurebreakable behaviour of showyboxes inside a figureSpecial thanks to Andrew Voynov (https://github.com/Andrew15-5) for the feedback while creating the new behaviours for boxed-titles
type() conditionals to Typst 0.8.0 standardsboxed-style property, with anchor, offset and radius properties.showy-inset() for being general-purpose. Now it's called showy-value-in-direction() and has a default value for handling properties defaultsradius (e.g. radius: (top: 5pt, bottom: 0pt)). Before this only was possible for untitled showyboxes.offset value.width of less than 100%, and a shadow.boxed option in title stylesboxed-align in title stylessep-thickness for title and footerChanges below were performed by Jonas Neugebauer (https://github.com/jneug)
title-inset, body-inset, footer-inset and inset options
title-inset, body-inset and footer-inset will set the inset of the title, body and footer area respectively. inset is a fallback for those areas.sep.gutter option to set the spacing around separator lineswidth to set the width of a showyboxalign to move a showybox with width < 100% along the x-axis
spacing, above and below to #showybox().footer and footer-style options
All changes listed here were performed by Jonas Neugebauer (https://github.com/jneug)
shadow optionbreakable) functionality for titled showyboxes0pt, probably due to some "fixes" improved to manage default spacing between rect elements. The issue was solved by avoiding #set statements and adding a #v(-1.1em) to correct extra spacing between the title rect and the body rect.Typst
100.0%
A Typst package for creating colorful and customizable boxes
Typst
149
132 commits
updated Jul 28, 2025
Showybox is a Typst package for creating colorful and customizable boxes.
Please note that this repository contains the latest (development) version of this package and may not yet be published at Typst's official package repository. If you want to use this package, see https://github.com/typst/packages/tree/main/packages/preview for the latest stable version
To use this library through the Typst package manager (for Typst 0.6.0 or greater), write #import "@preview/showybox:2.0.4": showybox at the beginning of your Typst file.
Once imported, you can create an empty showybox by using the function showybox() and giving a default body content inside the parenthesis or outside them using squared brackets [].
By default a showybox with these properties will be created:
5pt of border radius1pt of border thickness#import "@preview/showybox:2.0.4": showybox
#showybox(
[Hello world!]
)
Looks quite simple, but the "magic" starts when adding a title, color and shadows. The following code creates two "unique" boxes with defined colors and custom borders:
// First showybox
#showybox(
frame: (
border-color: red.darken(50%),
title-color: red.lighten(60%),
body-color: red.lighten(80%)
),
title-style: (
color: black,
weight: "regular",
align: center
),
shadow: (
offset: 3pt,
),
title: "Red-ish showybox with separated sections!",
lorem(20),
lorem(12)
)
// Second showybox
#showybox(
frame: (
dash: "dashed",
border-color: red.darken(40%)
),
body-style: (
align: center
),
sep: (
dash: "dashed"
),
shadow: (
offset: (x: 2pt, y: 3pt),
color: yellow.lighten(70%)
),
[This is an important message!],
[Be careful outside. There are dangerous bananas!]
)
The showybox() function can receive the following parameters:
title: A string used as the title of the showyboxfooter: A string used as the footer of the showyboxframe: A dictionary containing the frame's propertiestitle-style: A dictionary containing the title's stylesbody-style: A dictionary containing the body's stylesfooter-style: A dictionary containing the footer's stylessep: A dictionary containing the separator's propertiesshadow: A dictionary containing the shadow's propertieswidth: A relative length indicating the showybox's widthalign: An unidimensional alignment for the showybox in the pagebreakable: A boolean indicating whether a showybox can break if it reached an end of pagespacing: Space above and below the showyboxabove: Space above the showyboxbelow: Space below the showyboxbody: The content of the showyboxtitle-color: Color used as background color where the title goes (default is black)body-color: Color used as background color where the body goes (default is white)footer-color: Color used as background color where the footer goes (default is luma(85))border-color: Color used for the showybox's border (default is black)inset: Inset used for title, body and footer elements (default is (x: 1em, y: 0.65em)) if none of the followings are given:
title-inset: Inset used for the titlebody-inset: Inset used for the bodyfooter-inset: Inset used for the bodyradius: Showybox's radius (default is 5pt)thickness: Border thickness of the showybox (default is 1pt)dash: Showybox's border style (default is solid)color: Text color (default is white)weight: Text weight (default is bold)align: Text align (default is start)sep-thickness: Thickness of the separator between title and body (default is 1pt)boxed-style: If it's a dictionary of properties, indicates that the title must appear like a "floating box" above the showybox. If it's none, the title appears normally (default is none)anchor: Anchor of the boxed title
y: Vertical anchor (top, horizon or bottom -- default is horizon)x: Horizontal anchor (left, start, center, right, end -- default is start)offset: How much to offset the boxed title in x and y direction as a dictionary with keys x and y (default is 0pt)radius: Boxed title radius as a dictionary or relative length (default is 5pt)color: Text color (default is black)align: Text align (default is start)color: Text color (default is luma(85))weight: Text weight (default is regular)align: Text align (default is start)sep-thickness: Thickness of the separator between body and footer (default is 1pt)thickness: Separator's thickness (default is 1pt)dash: Separator's style (as a line dash style, default is "solid")gutter: Separator's space above and below (default is 0.65em)color: Shadow color (default is black)offset: How much to offset the shadow in x and y direction either as a length or a dictionary with keys x and y (default is 4pt)
Special thanks to enklht (https://github.com/enklht) and PgBiel (https://github.com/PgBiel) for their collaboration with this version's changes
start, instead of leftcounter inside a showybox declarationanchor inside a figurebreakable behaviour of showyboxes inside a figureSpecial thanks to Andrew Voynov (https://github.com/Andrew15-5) for the feedback while creating the new behaviours for boxed-titles
type() conditionals to Typst 0.8.0 standardsboxed-style property, with anchor, offset and radius properties.showy-inset() for being general-purpose. Now it's called showy-value-in-direction() and has a default value for handling properties defaultsradius (e.g. radius: (top: 5pt, bottom: 0pt)). Before this only was possible for untitled showyboxes.offset value.width of less than 100%, and a shadow.boxed option in title stylesboxed-align in title stylessep-thickness for title and footerChanges below were performed by Jonas Neugebauer (https://github.com/jneug)
title-inset, body-inset, footer-inset and inset options
title-inset, body-inset and footer-inset will set the inset of the title, body and footer area respectively. inset is a fallback for those areas.sep.gutter option to set the spacing around separator lineswidth to set the width of a showyboxalign to move a showybox with width < 100% along the x-axis
spacing, above and below to #showybox().footer and footer-style options
All changes listed here were performed by Jonas Neugebauer (https://github.com/jneug)
shadow optionbreakable) functionality for titled showyboxes0pt, probably due to some "fixes" improved to manage default spacing between rect elements. The issue was solved by avoiding #set statements and adding a #v(-1.1em) to correct extra spacing between the title rect and the body rect.Typst
100.0%