 Search
guides/style-guide: Style Guide guides/style-guide: ## Box Model guides/style-guide: ## Text plugins/plugin-dev: Developing Plugins plugins/plugin-dev: ### Style Layers components/input: Input components/input: ## Import components/input: ## Usage components/input: ### box- components/input: ### size- components/input: ### Extending plugins/plugin-nf: Nerd Font Plugin plugins/plugin-nf: ## Installation plugins/plugin-nf: ## Install a Nerd Font plugins/plugin-nf: ### Static Font plugins/plugin-nf: ### CDN plugins/plugin-nf: ## Components plugins/plugin-nf: ### <details> plugins/plugin-nf: ### Badge plugins/plugin-nf: #### cap- components/badge: Badge components/badge: ## Import components/badge: ## Usage components/badge: ### variant- components/badge: ### Styling components/badge: ### Extending components/badge: ## Scope start/ascii-boxes: ASCII Boxes start/ascii-boxes: ## Usage start/ascii-boxes: ## Border Types start/ascii-boxes: ## Containment start/ascii-boxes: ## Custom Properties start/ascii-boxes: ### --box-border-color start/ascii-boxes: ### --box-rounded-radius start/ascii-boxes: ### --box-border-width start/ascii-boxes: ### --box-double-border-width plugins/theme-nord: Nord Theme plugins/theme-nord: ## Installation plugins/theme-nord: ## Components plugins/theme-nord: ### Typography plugins/theme-nord: ### Badge plugins/theme-nord: ### Button plugins/theme-nord: ## CSS Variables components/button: Button components/button: ## Import components/button: ## Usage components/button: ### box- components/button: ### variant- components/button: ### size- components/button: ### disabled components/button: ### Styling components/button: ### Extending components/button: ## Scope plugins/theme-catppuccin: Catppuccin Theme plugins/theme-catppuccin: ## Installation plugins/theme-catppuccin: ## Flavors plugins/theme-catppuccin: ## Components plugins/theme-catppuccin: ### Typography plugins/theme-catppuccin: ### Badge plugins/theme-catppuccin: ### Button plugins/theme-catppuccin: ## CSS Variables plugins/theme-gruvbox: Gruvbox Theme plugins/theme-gruvbox: ## Installation plugins/theme-gruvbox: ## Variants plugins/theme-gruvbox: ## Components plugins/theme-gruvbox: ### Typography plugins/theme-gruvbox: ### Badge plugins/theme-gruvbox: ### Button plugins/theme-gruvbox: ## CSS Variables components/typography: Typography components/typography: ## Import components/typography: ## Usage components/typography: ### <h1>-<h6> components/typography: ### <p> components/typography: ### <blockquote> components/typography: ### <ol> components/typography: ### <ul> components/typography: #### <ul> Markers components/typography: ### [is-="typography-block"] components/typography: ## Scope start/intro: Introduction start/intro: ## Features start/installation: Installation start/installation: ## Installation start/installation: ## ESM Imports start/installation: ## CDN Imports start/installation: ## Full Library Import start/plugins: Plugins start/plugins: ## Official Plugins start/plugins: ### Themes start/plugins: ## Community Plugins start/theming: Theming start/theming: ## CSS Variables start/theming: ### Font Styles start/theming: ### Colors start/theming: ### Light & Dark start/theming: ## Theme Plugins start/tuis-vs-guis: TUIs vs GUIs start/tuis-vs-guis: ## Monospace Fonts start/tuis-vs-guis: ## Character Cells

ASCII Boxes

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

Below is an example of what the box utility is capable of:

 box-demo.png

box-demo.png

Usage

Import the utility stylesheet

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

Add the box- attribute to any HTML element that supports pseudo-elements

<div box-="square">
  <h1>Hi Mom</h1>
</div>
 box-hi-mom.png

box-hi-mom.png

Important: The box- utility is suffixed with a dash (-). Using box="..." will not work

Border Types

The box utility supports three different border types:

<div box-="square">Square</div>
<div box-="round">Round</div>
<div box-="double">Double</div>
 box-types.png

box-types.png

Containment

The top and/or bottom lines of the box can be contained by adding the contain:* modifier to the box- attribute

  • box-="<type> contain:!top" will not contain the top line
  • box-="<type> contain:!bottom" will not contain the bottom line
  • box-="<type> contain:none" will not contain the top or bottom lines

Take a moment and observe the screenshot below

  • Highlighted in blue is the content of the box
  • Highlighted in green is the padding of the box
  • The box border lines are constructed with the CSS ::before and ::after pseudo-elements
  • The box border lines appear behind the content within the <div box-="*"> element
 box-containment.png

box-containment.png

Custom 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 the 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>