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.
pip install styVerified import paths — ran on the pinned version, not inferred.
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`).
Customize styling by directly assigning `Rule` objects to the registers (e.g., `fg.red = Rule(Render.rgb_fg, 255, 0, 0)`). Refer to the official documentation for current customization patterns.
Update all instances of `sty.rs.rs` to `sty.rs.ef` to correctly apply the reset effect. The `rs.all` property can be used to reset all styles simultaneously.
Review and adjust any custom grey color definitions or assumptions based on the new palette definitions. You can define custom colors using `Rule` and `Render` classes.
Adopt the direct import pattern: `from sty import fg, bg, ef, rs`. This makes your code cleaner and aligns with the library's design.
Instead of `register.set_style(...)`, directly assign `Rule` objects to define custom styles, e.g., `fg.custom_color = Rule(Render.rgb_fg, 100, 200, 50)`.
Change `sty.rs.rs` to `sty.rs.ef` or use `rs.all` to reset all styles. For example, `print(fg.red + 'text' + rs.ef)` or `print(fg.red + 'text' + rs.all)`.
Always import public symbols directly from the `sty` package, e.g., `from sty import fg, bg, ef, rs`. The `sty.lib` path is for internal use.
No dependency data recorded yet.