Skip to content

rashidlaasri/twlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

:package: rashidlaasri/twlog

twlog

Beautiful browser console.log with Tailwind CSS.

Issues GitHub pull requests npm weekly downloads npm total downloads GitHub release
Report Bug Β· Request Feature

Overview

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.

Features

  • 🎨 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

Setup

Installation

Install the package using npm:

npm install @rashidlaasri/twlog

Or using yarn:

yarn add @rashidlaasri/twlog

Or using pnpm:

pnpm add @rashidlaasri/twlog

Requirements

  • 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

Usage

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();

twlog hidden gem

Security alert

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();

twlog security alert

Inspiring quote

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();

twlog inspiring quote

Console debugging

import { twlog } from '@rashidlaasri/twlog';

twlog()
  .text('[DEBUG]', 'text-xs font-mono text-slate-400')
  .text('Fetching user data…', 'text-blue-400')
  .log();

twlog console debugging

Tips & Hints

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();

twlog tips and hints

Dev tools onboarding

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();

twlog onboarding

Marketing / Annoucement drops

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();

twlog marketing

API Reference

twlog()

Creates a new TwLogger instance.

Returns: TwLogger

.text(text: string, classes?: string)

Adds a text segment with optional Tailwind CSS classes.

Parameters:

  • text (string): The text to display
  • classes (string, optional): Tailwind CSS utility classes

Returns: TwLogger (for chaining)

.line(text: string, classes?: string)

Adds a text segment with newlines before and after.

Parameters:

  • text (string): The text to display
  • classes (string, optional): Tailwind CSS utility classes

Returns: TwLogger (for chaining)

.log()

Outputs all accumulated text segments to the console with their respective styles.

Returns: void

Development

Building the Project

npm run build

Running Tests

npm test

Linting

npm run lint

Formatting

npm run format

Reporting Issues

If you find a bug or have a feature request:

Check if the issue already exists in the Issues section, if not, please create one.

πŸ“ License

Copyright Β© 2025 @rashidlaasri.

This project is MIT licensed.

Show your support

Give a ⭐️ if this project helps you and follow me on X πŸ™ŒπŸΎ


Made with ❀️ for beautiful console logs

About

Beautiful browser console.log with Tailwind CSS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published