DEV Community

Cover image for Day 13: I love Boxes! šŸ“¦
Valeria
Valeria

Posted on

Day 13: I love Boxes! šŸ“¦

Who doesn't like boxes? Especially if there's something nice hidden in the box! Today we'll look at a tiny library that adds a box to any text: boxen.

As usual, install it with e.g. deno add npm:boxen and create a file, e.g. main.ts:

import boxen from "boxen";

console.log(boxen("Happy Holidays!", { padding: 1 }));
Enter fullscreen mode Exit fullscreen mode

And when you run it with deno run -A ./main.ts you should be able to see something like that:

There are some styling options you could apply, e.g. double or round borders and different color. Or, if you're up for it you could try and do something like that:

import boxen from "boxen";

console.log(
  boxen(
    boxen(
      boxen("Happy Holidays!", {
        padding: 1,
        borderStyle: "round",
        borderColor: "greenBright",
      }),
      {
        padding: 1,
        borderStyle: "round",
        borderColor: "yellowBright",
      }
    ),
    {
      padding: 1,
      borderStyle: "round",
      borderColor: "redBright",
    }
  )
);
Enter fullscreen mode Exit fullscreen mode

And get something like this:

Three colored borders around

Liked the content and would love to have more of it all year long?

Buy Me A Coffee

Top comments (3)

Collapse
 
moopet profile image
Ben Sinclair

This is a really fun little series.

Collapse
 
valeriavg profile image
Valeria

Thank you so much! Glad you liked it!

Collapse
 
nozibul_islam_113b1d5334f profile image
Nozibul Islam

Great.