 Search
components/badge: Badge components/button: Button components/checkbox: Checkbox components/input: Input components/popover: Popover components/typography: Typography plugins/plugin-nf: Nerd Font Plugin plugins/theme-catppuccin: Catppuccin Theme plugins/theme-nord: Nord Theme plugins/theme-gruvbox: Gruvbox Theme start/ascii-boxes: ASCII Boxes start/changelog: Changelog start/changelog: ## 0.0.5 start/changelog: ## 0.0.4 start/changelog: ## 0.0.3 start/changelog: ## 0.0.2 start/changelog: ## 0.0.1 start/intro: Introduction start/intro: ## Features start/plugins: Plugins start/plugins: ## Official Plugins start/plugins: ### Themes start/plugins: ## Community Plugins contributing/contributing: Contributing contributing/contributing: ## Local Development contributing/contributing: ## Issues contributing/contributing: ## Pull Requests contributing/style-guide: Style Guide contributing/style-guide: ## CSS Units contributing/style-guide: ## Selectors contributing/style-guide: ## Documentation plugins/plugin-dev: Developing Plugins plugins/plugin-dev: ### Style Layers start/tuis-vs-guis: TUIs vs GUIs start/tuis-vs-guis: ## Monospace Fonts start/tuis-vs-guis: ## Character Cells installation/nextjs: Next.js installation/vite: Vite start/theming: Theming start/theming: ## CSS Variables start/theming: ### Font Styles start/theming: ### Colors start/theming: ### Light & Dark start/theming: ## Theme Plugins installation/astro: Astro installation/astro: ## Scoping installation/astro: ### Frontmatter Imports installation/astro: ### <style> tag installation/astro: ### Full Library Import start/installation: Installation start/installation: ## Installation start/installation: ## Using CSS start/installation: ## Using ESM start/installation: ## Using a CDN start/installation: ## Full Library Import start/installation: ### CSS start/installation: ### ESM start/installation: ### CDN

ASCII Boxes

The box- utility utilizes CSS ::before and ::after pseudo-elements to mimic a boxes drawn with ASCII Box-drawing characters

<div box-="square contain:none">
  <div class="header">
      <span is-="badge" variant-="background0">top-left</span>
      <span is-="badge" variant-="background0">top-right</span>
  </div>
  <div id="content">
      <p>Lorem ipsum dolor sit amet sit dolor ipsum lorem idk i dont speak french</p>
      <div id="buttons">
          <button box-="round">Cancel</button>
          <button box-="round">Ok</button>
      </div>
  </div>
  <div class="header">
      <span is-="badge" variant-="background0">bottom-left</span>
      <span is-="badge" variant-="background0">bottom-right</span>
  </div>
</div>
.header { 
  display: flex;
  justify-content: space-between; 
}
#content { 
  padding: 0lh 1ch;
  padding-top: 1lh;
  display: flex;
  flex-direction: column;
  gap: 1lh;
}
#buttons { 
  display: flex; 
  justify-content: flex-end; 
}

Import

@import "@webtui/css/utils/box.css";

Usage

<div box-="square">
  Hi Mom
</div>

Important: The box- utility is suffixed with a -

Using box="..." will not work

Examples

Box Border Types

<div box-="square">Square</div>
<div box-="round">Round</div>
<div box-="double">Double</div>

Containment

Choose whether to contain the top and/or bottom lines of the box

<!-- Do not contain the top row -->
<div box-="square contain:!top">
  <div class="header">
      <span>Left</span>
      <span>Right</span>
  </div>
  Caption on Top
</div>

<!-- Do not contain the bottom row -->
<div box-="square contain:!bottom">
  Caption on Bottom
  <div class="header">
      <span>Left</span>
      <span>Right</span>
  </div>
</div>

<!-- Do not contain the top or bottom rows -->
<div box-="square contain:none">
  <div class="header">
      <span>Left</span>
      <span>Right</span>
  </div>
  Caption on Top and Bottom
  <div class="header">
      <span>Left</span>
      <span>Right</span>
  </div>
</div>
.header { 
      display: flex;
      justify-content: space-between; 
}
span {
  background-color: var(--background0);
  padding: 0 1ch;
}

Properties

Elements with the box- attribute can be customized via Custom CSS properties [MDN Reference]

--box-border-color

The border color of the box

  • Syntax: <color>
  • Default Value: var(--foreground0)
<style>
  #my-box {
    --box-border-color: red;
  }
</style>

<div box-="square" id="my-box"></div>

--box-rounded-radius

The border radius of round boxes

  • Syntax: <length>
  • Default Value: 4px
<style>
  #my-box {
    --box-rounded-radius: 10px;
  }
</style>

<div box-="round" id="my-box"></div>

--box-border-width

The border width for square and round boxes

  • Syntax: <length>
  • Default Value: 2px
<style>
  #my-box {
    --box-border-width: 10px;
  }
</style>

<div box-="square" id="my-box"></div>

--box-double-border-width

The width of boxes with double borders

  • Syntax: <length>
  • Default Value: 1px
<style>
  #my-box {
    --box-double-border-width: 10px;
  }
</style>