Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A cross-platform V library for creating beautiful terminal spinner animations. Perfect for enhancing your CLI applications with engaging loading indicators.

License

Notifications You must be signed in to change notification settings

sw3do/spinner-v

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spinner-V 🌀

Note: This is my first time trying the V programming language - it's quite weird, honestly! There are some bugs in this project, but I wanted to share it anyway.

A cross-platform V library for creating beautiful terminal spinner animations. Perfect for enhancing your CLI applications with engaging loading indicators.

Features

  • 🎨 30+ Built-in Spinner Styles - From simple dots to complex animations
  • 🌈 Color Support - 7 different colors available
  • Cross-Platform - Works on Windows, macOS, and Linux
  • 🔧 Customizable - Adjust speed, messages, and colors
  • 📱 Lightweight - Zero dependencies, pure V implementation
  • 🎯 Easy to Use - Simple API for quick integration

Installation

v install spinner

Or add to your v.mod:

dependencies: ['spinner']

Quick Start

import spinner
import time

fn main() {
    mut s := spinner.new_spinner(.dots)
    s.set_message('Loading...')
    s.set_color('green')
    s.start()
    
    time.sleep(3 * time.second)
    
    s.finish_with_message('✓ Done!')
}

Available Spinner Styles

Style Animation Description
dots ⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏ Classic braille dots
line |/-\ Simple line rotation
circle ◐◓◑◒ Rotating circle
arrow ←↖↑↗→↘↓↙ Rotating arrow
bouncingbar [====] Bouncing progress bar
bouncingball ( ● ) Bouncing ball
pulsing ●◉⊙◯○ Pulsing circle
clock 🕐🕑🕒🕓 Clock animation
earth 🌍🌎🌏 Rotating earth
moon 🌑🌒🌓🌔🌕 Moon phases
runner 🚶🏃 Running person
pong ▐⠂ ▌ Pong game
shark ▐|\____________▌ Swimming shark
weather ☀️🌤⛅️🌧 Weather changes
mindblown 😐😮🤯💥 Mind blown sequence
soccerHeader ⚽️🧑 Soccer header
timeTravel 🕐🕛🕧 Time travel effect
aesthetic ▰▰▰▰▰▰▰ Aesthetic progress

API Reference

Creating a Spinner

spinner.new_spinner(style SpinnerStyle) Spinner

Configuration Methods

set_message(message string)        // Set spinner message
set_color(color string)           // Set spinner color
set_delay(delay time.Duration)    // Set animation speed

Control Methods

start()                          // Start the spinner
stop()                          // Stop the spinner
finish_with_message(msg string) // Stop with final message
update_message(msg string)      // Update message while running

Available Colors

  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

Examples

Basic Usage

import spinner
import time

mut s := spinner.new_spinner(.dots)
s.set_message('Processing...')
s.start()
time.sleep(2 * time.second)
s.stop()

Colored Spinner

mut s := spinner.new_spinner(.circle)
s.set_message('Downloading...')
s.set_color('blue')
s.start()
time.sleep(3 * time.second)
s.finish_with_message('✓ Download complete!')

Dynamic Messages

mut s := spinner.new_spinner(.bouncingball)
s.set_message('Initializing...')
s.start()

time.sleep(1 * time.second)
s.update_message('Connecting...')

time.sleep(1 * time.second)
s.update_message('Loading data...')

time.sleep(1 * time.second)
s.finish_with_message('✓ Ready!')

Custom Speed

mut s := spinner.new_spinner(.aesthetic)
s.set_delay(50 * time.millisecond)  // Faster animation
s.set_message('Fast loading...')
s.start()
time.sleep(2 * time.second)
s.stop()

Running the Example

v run example.v

This will demonstrate various spinner styles and configurations.

Cross-Platform Compatibility

The library uses ANSI escape sequences for cursor control and colors, making it compatible with:

  • Linux - All major distributions
  • macOS - Terminal.app, iTerm2, and others
  • Windows - Windows Terminal, PowerShell, CMD (Windows 10+)

Contributing

Contributions are welcome! Feel free to:

  • Add new spinner styles
  • Improve cross-platform compatibility
  • Fix bugs or enhance performance
  • Improve documentation

License

MIT License - see LICENSE file for details.

Inspiration

Inspired by similar spinner libraries in other languages, bringing beautiful terminal animations to the V ecosystem.

About

A cross-platform V library for creating beautiful terminal spinner animations. Perfect for enhancing your CLI applications with engaging loading indicators.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published