Beautiful browser console.log with Tailwind CSS.
twlog is a small package that allows you to create beautifully styled console.log messages using Tailwind CSS classes. Transform your browser console output with custom styling, colors, and formatting - all using familiar Tailwind utility classes.
- π¨ Tailwind CSS Integration - Use any Tailwind CSS utility classes to style your console output
- π Fluent API - Chainable methods for intuitive usage
- π Multiple Text Segments - Combine multiple styled text segments in a single log
- π― TypeScript Support - Full TypeScript definitions included
- π Zero Dependencies - Lightweight and fast
- π§ͺ Well Tested - Comprehensive test coverage
Install the package using npm:
npm install @rashidlaasri/twlogOr using yarn:
yarn add @rashidlaasri/twlogOr using pnpm:
pnpm add @rashidlaasri/twlog- Browser Environment: This package requires a browser environment with DOM APIs (
document,getComputedStyle) - Tailwind CSS: Your project should have Tailwind CSS configured and loaded in the browser
The twlog() function lets you style your browser console logs using real Tailwind CSS classes β so you can make debugging, announcements, or Easter eggs look beautiful and on-brand.
Each message is built with a fluent, chainable API. Now here are some fun and useful examples π
Hidden gem
import { twlog } from '@rashidlaasri/twlog';
twlog()
.line('π You found a hidden message!', 'text-pink-400 text-lg font-semibold')
.text('We like curious people like you π»', 'text-slate-300 italic')
.line('We\'re hiring β join us!', 'text-green-400 font-bold')
.text('π careers.example.com', 'bg-green-500/10 text-green-400 px-2 py-1 rounded-md underline')
.log();import { twlog } from '@rashidlaasri/twlog';
twlog()
.line('β οΈ STOP!', 'text-5xl font-extrabold text-red-500')
.line('This browser feature is intended for developers.', 'text-yellow-400 text-lg font-semibold mt-2')
.text(
'If someone told you to copy and paste something here to enable a feature or hack an account, itβs a scam and will give them access to your account.',
'text-slate-500 mt-2 leading-snug'
)
.line('Stay safe π', 'text-blue-400 font-bold mt-2')
.log();import { twlog } from '@rashidlaasri/twlog';
twlog()
.line('βSimplicity is the soul of efficiency.β', 'text-purple-300 italic')
.text('- Austin Freeman', 'text-slate-500 text-sm ml-2')
.log();import { twlog } from '@rashidlaasri/twlog';
twlog()
.text('[DEBUG]', 'text-xs font-mono text-slate-400')
.text('Fetching user dataβ¦', 'text-blue-400')
.log();import { twlog } from '@rashidlaasri/twlog';
twlog()
.text('π‘ Tip:', 'bg-amber-400/10 text-amber-400 inset-ring inset-ring-amber-400/20 font-medium px-2 py-1 rounded-md')
.text('Use `twlog()` for stylish debugging β¨', 'text-slate-300 ml-2')
.log();import { twlog } from '@rashidlaasri/twlog';
twlog()
.line('π Welcome to the dev console!', 'text-emerald-400 font-semibold text-lg')
.text('This project uses Tailwind, Vue, and Vite.', 'text-slate-300 italic')
.text('Find our docs at β dev.example.com/docs', 'text-blue-400 underline')
.log();import { twlog } from '@rashidlaasri/twlog';
twlog()
.text('π₯ New Feature Released:', 'text-pink-400 font-bold')
.text('Dark Mode is now live! π', 'text-white bg-slate-800 px-2 py-1 rounded')
.text('Try it now β example.com/settings', 'text-sky-400 underline ml-2')
.log();Creates a new TwLogger instance.
Returns: TwLogger
Adds a text segment with optional Tailwind CSS classes.
Parameters:
text(string): The text to displayclasses(string, optional): Tailwind CSS utility classes
Returns: TwLogger (for chaining)
Adds a text segment with newlines before and after.
Parameters:
text(string): The text to displayclasses(string, optional): Tailwind CSS utility classes
Returns: TwLogger (for chaining)
Outputs all accumulated text segments to the console with their respective styles.
Returns: void
npm run buildnpm testnpm run lintnpm run formatIf you find a bug or have a feature request:
Check if the issue already exists in the Issues section, if not, please create one.
Copyright Β© 2025 @rashidlaasri.
This project is MIT licensed.
Give a βοΈ if this project helps you and follow me on X ππΎ
Made with β€οΈ for beautiful console logs







