 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

TUIs vs GUIs

Terminal UIs (TUIs) use ASCII/Unicode characters to represent UI elements

Graphical UIs (GUIs) instead use graphical elements like windows, buttons, inputs, etc

To build Terminal-like UIs, you will need to

Monospace Fonts

In most traditional fonts, some characters (like i) are narrower than others (like w)

All characters in Monospace Fonts occupy the same width

This makes it easier to align characters

It also makes it easier to create ASCII art

         _nnnn_
        dGGGGMMb
       @p~qp~~qMb
       M|@||@) M|
       @,----.JM|
      JS^\__/  qKL
     dZP        qKRb
    dZP          qKKb
   fZP            SMMb
   HZM            MMMM
   FqM            MMMM
 __| ".        |\dS"qML
 |    `.       | `' \Zq
_)      \.___.,|     .'
\____   )MMMMMP|   .'
     `-'       `--' hjm

Character Cells

Stop thinking in standard CSS units like px, em, rem, %

Start thinking in Character Cells for spacing, sizing, and positioning

CSS comes with two units that represent the width and height of a single character cell:

  • ch is equal to the character width of the 0 glyph in the current font [MDN Reference]
  • lh is equal to the line height of the element on which it is used [MDN Reference]

Remember that when using a Monospace font, every character has the same width, so ch applies for all characters

If I were to create a box that is 10 characters wide and 5 lines tall, I would use the following CSS:

.box {
  width: 10ch;
  height: 5lh;
}

Now that you understand the differences between building TUIs and GUIs, let’s dive in