Day 13: I love Boxes! 📦
Valeria

Valeria @valeriavg

About: Re-inventor extraordinaire, optimisation addict and open web advocate.

Location:
Stockholm, Sweden
Joined:
Sep 23, 2020

Day 13: I love Boxes! 📦

Publish Date: Dec 13 '24
8 3

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

Comments 3 total

Add comment