lucent 0.1.2
lucent: ^0.1.2 copied to clipboard
Lucent is a powerful and expressive terminal styling library for Dart
Lucent is a powerful and expressive terminal styling library for Dart, inspired by Python's Rich. It allows you to style terminal output with ease, supporting nested styles, truecolor, and intelligent fallbacks for terminals with limited capabilities.

✨ Features #
- Rich Markup Syntax – Use tags like
[bold red]Error:[/]for styled output. - Truecolor Support – Use 24-bit RGB with
[color(#ff33aa)]or[on rgb(255, 255, 0)]. - 256-Color & 4-Bit Fallbacks – Automatically converts to nearest match based on terminal.
- Named Colors – CSS-like color names:
[color(tomato)],[on slategray], etc. - Style Nesting – Combine
[bold underline red]and more. - Dumb Terminal Detection – Automatically disables styling for
TERM=dumb. - Manual Styling Control – Enable/disable styling and silence warnings.
🚀 Getting Started #
Installation #
Add to pubspec.yaml:
dependencies:
lucent: ^0.1.0
Then install:
dart pub get
Basic Usage #
import 'package:lucent/lucent.dart';
void main() {
Console.print('[bold green]Success:[/] Operation completed.');
}
🎨 Advanced Styling #
Nested Styles #
Console.print('[bold red]Error: [underline]File not found[/][/]');
Truecolor (24-bit) #
Console.print('[color(#ff33aa)]Pink Text[/]');
Console.print('[on rgb(255, 255, 0)]Yellow Background[/]');
Named Colors #
Console.print('[color(tomato)]Tomato Text[/]');
Console.print('[on slategray]Slate Gray Background[/]');
🧠 Terminal Compatibility #
Lucent automatically detects and adapts to the terminal:
| Terminal | Output |
|---|---|
| TERM=dumb | No styling (safe) |
| 4-bit (ANSI) | 16 colors |
| 8-bit (xterm-256) | 256-color palette |
| Truecolor | Full 24-bit RGB |
Manually override behavior:
enableStyling(); // Force styling on
disableStyling(); // Disable all styling
silentMode(); // Suppress warnings
📦 API Reference #
Console.print(String markup)enableStyling([bool enabled = true])disableStyling()silentMode()
🧪 Examples #
Console.print('[bold blue]Info:[/] App started');
Console.print('[italic yellow]Warning:[/] Low disk space');
Console.print('[underline red]Error:[/] Connection failed');
Console.print('[color(#00ffaa) on #222222] Custom truecolor text [/]');
Console.print('[bold color(tomato) on gold] Tasty styled message [/]');
Lucent is inspired by the Rich Python library.