cli-colors-pro
v1.0.1
Published
Make your terminal output colorful and beautiful — zero dependencies!
Readme
cli-colors-pro
Make your terminal output colorful and beautiful — zero dependencies!
Installation
npm install cli-colors-proQuick Start
import c from 'cli-colors-pro';
console.log(c.green('Hello World!'));
console.log(c.bold(c.red('Something went wrong!')));
c.success('Server started on port 3000');
c.error('Database connection failed');Features
| Feature | Description | |---------------------|--------------------------------------------------| | Text Colors | red, green, yellow, blue, magenta, cyan, white | | Bright Colors | brightRed, brightGreen, brightYellow, brightCyan | | Background Colors | bgRed, bgGreen, bgYellow, bgBlue, bgCyan | | Text Styles | bold, italic, underline, dim, strikethrough | | Log Helpers | success, error, warn, info, debug | | Box | Draw a Unicode border around any text | | Progress Bar | Render a colored progress bar | | Multi-style | Apply multiple styles at once | | Zero Dependencies | No external packages needed |
API Reference
Text Colors
c.red('text')
c.green('text')
c.yellow('text')
c.blue('text')
c.magenta('text')
c.cyan('text')
c.white('text')Bright Colors
c.brightRed('text')
c.brightGreen('text')
c.brightYellow('text')
c.brightBlue('text')
c.brightCyan('text')Background Colors
c.bgRed('text')
c.bgGreen('text')
c.bgYellow('text')
c.bgBlue('text')
c.bgCyan('text')
c.bgMagenta('text')Text Styles
c.bold('text')
c.italic('text')
c.underline('text')
c.dim('text')
c.strikethrough('text')Apply Multiple Styles At Once
// Usage: c.style(text, ...styles)
c.style('Hello', 'bold', 'red', 'underline')
c.style('World', 'bgBlue', 'white', 'bold')Log Helpers
c.success('User created successfully');
// Output: SUCCESS User created successfully (in green)
c.error('File not found');
// Output: ERROR File not found (in red)
c.warn('Memory usage is high');
// Output: WARN Memory usage is high (in yellow)
c.info('Server running on port 3000');
// Output: INFO Server running on port 3000 (in cyan)
c.debug('Response time: 120ms');
// Output: DEBUG Response time: 120ms (dimmed)Box
// Usage: c.box(text, color?)
console.log(c.box('Deployment Complete!', 'green'));
// Output:
// ┌─────────────────────────┐
// │ Deployment Complete! │
// └─────────────────────────┘Progress Bar
// Usage: c.progressBar(percent, width?, color?)
console.log(c.progressBar(75));
// Output: [██████████████████████░░░░░░░░] 75%
console.log(c.progressBar(50, 20, 'cyan'));
// Output: [██████████░░░░░░░░░░] 50%Chain API
// Chain multiple styles together
const styled = c.color('Hello World').red.bold.underline;
console.log(styled.toString());
// Or print directly
c.color('Hello World').green.bold.print();Full Example
import c from 'cli-colors-pro';
// Colored text
console.log(c.red('Error occurred!'));
console.log(c.green('All systems go!'));
// Combined styles
console.log(c.style('Warning!', 'bold', 'yellow', 'underline'));
// Log helpers
c.success('Build completed in 3.2s');
c.error('Could not connect to database');
c.warn('Deprecated API used');
c.info('Listening on http://localhost:3000');
c.debug('Cache hit ratio: 94%');
// Progress bar
console.log('Uploading: ' + c.progressBar(80, 30, 'cyan'));
// Box
console.log(c.box(' Deployment Successful! ', 'green'));License
MIT © Saqib Aziz
