DEV Community

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

Posted on

6 1 1

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

Image of Timescale

Timescale ā€“ the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

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.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

šŸ‘‹ Kindness is contagious

Please leave a ā¤ļø or a friendly comment on this post if you found it helpful!

Okay