omarcoaraujo/tint
v0.1.1 ·
Terminal string styling library for Luau
Features
- Fluent chainable API —
tint.red.bold.underline("text") - Nested styles with automatic color restoration
- True color RGB and hex support with automatic downgrading per terminal capability
- Automatic terminal color level detection (respects
NO_COLOR,FORCE_COLOR,COLORTERM, etc.) - Runtime agnostic — works with Zune, Lune, and Lute
- Zero dependencies
Installation
Add Tint to your pesde.toml:
[dependencies]
tint = { name = "omarcoaraujo/tint", version = "^0.1.0" }
Then require it:
local tint = require("@pkg/tint")
Usage
Basic colors
print(tint.red("ERROR"))
print(tint.green("SUCCESS"))
print(tint.yellow("WARNING"))
print(tint.blue("INFO"))
print(tint.cyan("note"))
Modifiers
print(tint.bold("bold"))
print(tint.italic("italic"))
print(tint.underline("underline"))
print(tint.dim("dim"))
print(tint.strikethrough("strikethrough"))
Chaining
Styles can be chained in any order:
print(tint.red.bold("red and bold"))
print(tint.blue.bold.underline("important"))
print(tint.green.italic("success"))
Nesting
Outer colors are automatically restored after inner styled segments:
print(tint.red("error: ", tint.yellow("detail"), " continues in red"))
print(tint.bold("BOLD ", tint.underline("BOLD+UNDERLINE"), " BOLD again"))
True color (RGB & Hex)
print(tint.rgb(255, 136, 0)("orange"))
print(tint.hex("#ff8800")("also orange"))
print(tint.rgb(255, 136, 0).bold("bold orange"))
-- Background
print(tint.bg_rgb(30, 30, 46)("text on dark bg"))
print(tint.bg_hex("#1e1e2e")("text on hex bg"))
On terminals that do not support true color, RGB and hex values are automatically downgraded to the nearest 256-color or 16-color equivalent.
Background colors
print(tint.bg_red("red background"))
print(tint.bg_green("green background"))
print(tint.red(tint.bg_white("red text on white background")))
Color level detection
Tint detects color support automatically at startup and adapts all output accordingly.
| Level | Description | Triggered by |
|---|---|---|
0 | No colors | NO_COLOR, TERM=dumb, pipe / non-TTY |
1 | Basic 16 colors | Most terminals, CI environments |
2 | 256 colors | TERM=xterm-256color |
3 | True color (16M) | COLORTERM=truecolor, Windows Terminal, iTerm 3+ |
Overriding
FORCE_COLOR=0 zune run script.lua # disable all colors
FORCE_COLOR=3 zune run script.lua # force true color
NO_COLOR=1 zune run script.lua # disable per no-color.org spec
Or via CLI flags:
zune run script.lua --no-color # disable colors
zune run script.lua --color=256 # force 256 color mode
Runtime compatibility
Tint works across Luau runtimes with automatic detection:
| Runtime | Color support | TTY detection |
|---|---|---|
| Zune | Full | Yes |
| Lune | Full | No (assumes TTY) |
| Lute | Full | No (assumes TTY) |
License
MIT