Showybox Typst Package

repository·main·Indexed 40 days ago

https://github.com/pablo-gonzalez-calderon/showybox-package

A Typst package for creating customizable, colorful, and styled boxes for document layout. Supports features such as titles, footers, shadows, and floating 'boxed' titles. Compatible with Typst 0.6.0 or greater.

Tokens
1.4K
Snippets
10
Records
10
Agent score
50%

What's inside Showybox

  1. Use boxed titles

    main

    When boxed-style is used in title-style, you can further customize the floating title box using these properties within the boxed-style dictionary:

    • anchor: The position of the box relative to the main box.
      • y: Vertical anchor (top, horizon, or bottom; default: horizon)
      • x: Horizontal anchor (left, start, center, right, or end; default: start)
    • offset: A dictionary {x: length, y: length} to offset the box (default: 0pt)
    • radius: The radius of the boxed title (default: 5pt)
    #showybox(
      title: "Floating Title",
      title-style: (
        boxed-style: (
          anchor: (x: "center", y: "top"),
          offset: (x: 0pt, y: -5pt),
          radius: 3pt
        )
      )
    )
  2. Create a basic showybox

    main

    You can create a simple box by calling showybox() and providing content either inside the parentheses or using squared brackets []. By default, a showybox has no title, no shadow, black borders, a white background, a 5pt border radius, and a 1pt border thickness.

    #showybox(
      [Hello world!]
    )
  3. Style the showybox title

    main

    Use the title-style dictionary to customize the appearance of the title text and its separator:

    • color: Text color (default: white)
    • weight: Text weight (default: bold)
    • align: Text alignment (default: start)
    • sep-thickness: Thickness of the line between title and body (default: 1pt)
    • boxed-style: If provided as a dictionary, the title renders as a "floating box" above the main box. If none, it renders normally.
    #showybox(
      title: "My Title",
      title-style: (
        color: black,
        weight: "regular",
        align: center
      )
    )
  4. Configure showybox frame properties

    main

    The frame parameter accepts a dictionary to control the background colors and borders of the box sections:

    • title-color: Background color for the title area (default: black)
    • body-color: Background color for the body area (default: white)
    • footer-color: Background color for the footer area (default: luma(85))
    • border-color: Color of the box border (default: black)
    • inset: Default inset for title, body, and footer (default: (x: 1em, y: 0.65em)). Can be overridden by title-inset, body-inset, or footer-inset.
    • radius: Corner radius (default: 5pt). Supports dictionary for specific corners (e.g., (top: 5pt, bottom: 0pt)).
    • thickness: Border thickness (default: 1pt)
    • dash: Border style (default: "solid")
    #showybox(
      frame: (
        border-color: red.darken(50%),
        title-color: red.lighten(60%),
        body-color: red.lighten(80%)
      )
    )
  5. Style the showybox footer

    main

    Use the footer (string) and footer-style (dictionary) parameters to add a bottom section:

    • footer-style.color: Text color (default: luma(85))
    • footer-style.weight: Text weight (default: regular)
    • footer-style.align: Text alignment (default: start)
    • footer-style.sep-thickness: Thickness of the line between body and footer (default: 1pt)
    #showybox(
      footer: "End of section",
      footer-style: (
        align: right,
        weight: "italic"
      )
    )
  6. Control showybox layout and breaking

    main

    Use these parameters to manage how the box sits on the page:

    • width: Relative length for the box width.
    • align: Unidimensional alignment for the box on the page.
    • breakable: Boolean. If true, the box can split across page boundaries (default: false).
    • spacing: Space above and below the entire box.
    • above: Specific space above the box.
    • below: Specific space below the box.
    #showybox(
      width: 80%,
      align: center,
      breakable: true,
      above: 1em
    )
  7. Configure separator properties

    main

    The sep dictionary controls the horizontal line used to separate sections (like title/body or body/footer):

    • thickness: Line thickness (default: 1pt)
    • dash: Line style (e.g., "solid", "dashed"; default: "solid")
    • gutter: Vertical space above and below the separator (default: 0.65em)
    #showybox(
      sep: (
        dash: "dashed",
        thickness: 2pt
      )
    )