ns Docsns Docs
Concepts

Gradients

Use expressive gradient presets for meaningful and aesthetic terminal output.

Gradients in nstypocolors are designed to be intentional, not decorative.

They help convey meaning at a glance—such as success, failure, or progress—without overwhelming the terminal.

Unlike noisy rainbow effects, these gradients are:

  • Carefully curated
  • Readable on dark terminals
  • Suitable for both short and long messages
Gradients are meant to highlight moments, not replace clear wording.

Basic Usage


Import only the gradient presets you need and use them directly.

import { logSuccess, logError, logInfo, logWarn, logBuild } from 'nstypocolors'

logSuccess('Operation completed successfully')
logError('Failed to connect to database')
logInfo('Fetching user data...')
logWarn('Disk usage is high')
logBuild('Building project...')
const { logSuccess, logError, logInfo, logWarn, logBuild } = require('nstypocolors')

logSuccess('Operation completed successfully')
logError('Failed to connect to database')
logInfo('Fetching user data...')
logWarn('Disk usage is high')
logBuild('Building project...')

Each function applies a smooth, multi-step gradient across the entire message.

Available Gradient Presets


Success

A green-blended success gradient, ideal for confirmations and completed tasks.

logSuccess('Deployment completed')
logSuccess('Deployment completed')

Recommended for:

  • Successful operations
  • Completed tasks
  • Positive outcomes

Error

A red → orange gradient for failures and critical issues.

logError('Runtime error occurred')
logError('Runtime error occurred')

Recommended for:

  • Errors
  • Crashes
  • Failed operations

Info

A blue → cyan gradient for neutral, informational messages.

logInfo('Connecting to server...')
logInfo('Connecting to server...')

Recommended for:

  • Status updates
  • Background operations
  • Informational logs

Warn

A yellow → orange gradient to indicate caution or potential issues.

logWarn('Deprecated API usage detected')
logWarn('Deprecated API usage detected')

Recommended for:

  • Warnings
  • Non-fatal issues
  • Attention-required messages

Build

A purple-based gradient, designed for build systems and developer workflows.

logBuild('Compiling source files...')
logBuild('Compiling source files...')

Default

A red-blended default gradient.

logDefault('Deployment completed')
logDefault('Deployment completed')

Use logDefault when no specific semantic gradient fits your message.

Recommended for:

  • Build steps
  • Tooling output
  • CI / CD logs

Short Messages & Edge Cases


Gradients safely adapt to very short messages.

logSuccess('OK')
logError('No')
logWarn('!')
logBuild('Hi')
logSuccess('OK')
logError('No')
logWarn('!')
logBuild('Hi')

Short messages rely more on wording than color intensity—this is expected behavior.

When to Use Gradients


  • Use colors for simple, predictable output
  • Use gradients for expressive, high-signal moments
  • Avoid stacking or mixing multiple gradients in a single block

Overusing gradients reduces clarity. Treat them as visual anchors, not decoration.

Gradients should enhance understanding—not distract from it.

Last updated on

On this page