Sty

1.0.6 · active · verified Thu Apr 16

Sty is a Python library that provides a simple, customizable, and performant string styling markup for terminal output, decoupled from specific color palettes and terminal implementations. It supports 3/4bit, 8bit, and 24bit (truecolor/RGB) colors, as well as effects like bold, italic, and underline. Currently at version 1.0.6, Sty follows semantic versioning and aims to maintain backward compatibility for 1.x.x releases after 1.0.0. It has no external dependencies and is actively maintained.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and apply various foreground and background colors, as well as text effects. It shows examples for standard, 8-bit, and 24-bit RGB colors, and how to combine and reset styles using the provided register objects (`fg`, `bg`, `ef`, `rs`).

from sty import fg, bg, ef, rs

# Basic colors
print(fg.red + 'This is red text!' + fg.rs)
print(bg.blue + 'This has a blue background!' + bg.rs)

# Effects
print(ef.bold + 'This is bold text' + ef.rs)
print(ef.italic + 'This is italic text' + ef.rs)

# 8-bit colors
print(fg(201) + 'This is pink text using 8bit colors' + fg.rs)

# 24-bit (RGB) colors
print(fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs)

# Combine styles
print(fg.green + bg.yellow + ef.bold + 'Green text on yellow background, bold!' + rs.all)

view raw JSON →