colorette – terminal text colour and styling library

colorette is a library for applying ANSI colours and text formatting to terminal output. It provides individual functions for colouring strings and applying effects such as bold, underline and dimmed text. Developers can combine these functions to format command-line messages without having to construct ANSI escape sequences themselves.

The library takes a function-based approach rather than providing a chainable styling object. Colour and formatting operations can be nested, and colorette handles the escape sequences needed to restore the surrounding formatting. It automatically determines whether terminal colouring is supported and can disable ANSI output when it is inappropriate, such as when text is redirected to another process. Applications can also create separately configured styling interfaces, allowing colour output to be controlled independently of the default detection behaviour. Colorette supports standard ANSI colours and bright variants, concentrating on straightforward formatting rather than extended RGB colour management.

This is free and open source software.

Key Features

  • Individual functions for applying ANSI foreground colours.
  • Standard and bright foreground colour variants.
  • Background colours with bright variants.
  • Formatting functions for bold, dim, italic, underline, hidden and strikethrough text.
  • Nested formatting with restoration of surrounding styles.
  • Automatic detection of terminal colour support.
  • isColorSupported property for querying colour availability.
  • createColors() function for creating independently configured formatting functions.
  • Manual colour configuration through the useColor option.
  • Support for –color and –no-color command-line options.
  • NO_COLOR and FORCE_COLOR environment variable support.
  • Functions can be combined within template literals.
  • TypeScript type declarations.
  • No runtime dependencies.

Website: github.com/jorgebucaran/colorette
Support:
Developer: Jorge Bucaran
License: MIT License

colorette is written in JavaScript. Learn JavaScript with our recommended free books and free tutorials.


Related Software

Terminal String Styling Tools
RichPython library for rich text and beautiful formatting
ChalkBills itself as “Terminal string styling done right”
picocolorsTiny and fast library for terminal output formatting
yoctocolorsSmall and fast command-line coloring package
yachalkClone of Chalk written in Python
kleurNode.js library for formatting terminal text with ANSI colors
coloretteSet your terminal text color and styles
styString styling for your terminal
termcolorANSI color formatting for output in the terminal
coloredSimple Python library for color and formatting in terminal
ansicolorsANSI colors for Python
ansi-colorsAdd ANSI colors to terminal text

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted