Skip to content
A powerful terminal spinner for your swift projects πŸ’»πŸ”₯
Branch: master
Clone or download

Swift CLI Spinners

Build Status GitHub release

Full featured Swift library for creating powerful terminal Spinners πŸ”₯

Key Features

  • Over 60 built in animations 🀩
  • Built in completion functions (Success, Failure, Warning, Information) βœ”
  • Easily create your own custom animations
  • Only bug free Spinner library built in Swift on Github


To install within your Swift project add the GitHub url to your Package.swift file as a dependency. Swift Package Manger will sort everything out for you when you run swift build πŸ’ͺ

.package(url: "", from: "1.1.0")

Getting Started

To create a simple for 2 seconds spinner:

import Spinner

let mySpinner = Spinner(.dots, "My Spinner")

Updating the user with a completion type can be useful for example:

mySpinner.succeed("Task Completed")


Creating a Spinner

When creating an instance of Spinner the initialiser takes the following arguments:

  • pattern: SpinnerPattern the pattern that the spinner will display
  • text: String the text that will displayed next to the spinner
  • speed: Double the speed the spinner will update at
  • color: Color the color of the spinner - default is
let mySpinner = Spinner(.dots, "My Spinner", speed: 0.5, color: .lightMagenta)

Starting the Spinner 🏁

To start a spinner call the .start() function. This will hide the curser and start the spinner animation.


Stopping the Spinner πŸ›‘

To stop a Spinner object calling .stop() will stop the animation on the current frame, return to a new line and unhide the curser. However to update the Spinner with a final frame and text can be extremely usefully for the user in some cased, to do this you can pass the following arguments to the .stop() function:

  • finalFrame: String The final frame the Spinner will display
  • text: String The text displayed by the Spinner once stopped
  • color: Color The color the Spinner will display the pattern in
mySpinner.stop(finalFrame: "!", text: "Final Text", .cyan)

Clearing the Spinner 🧽

It might be important to stop the Spinner and clear it at the same time, .clear() is the function to call if you're looking for this.


Completion Types βœ…

As you're using a spinner to display information to the user it might be usefully to provide a type when stopping the Spinner. There are 4 different built-in types for different states: .succeed(), .failure(), .warning() and .information(). Each completion type also takes these arguments:

  • text: String The text that will displayed next to the stopped Spinner

Creating Custom Patterns πŸ”₯

We have 60 animated spinner patterns for you to choose from however you may want to create your own. This can easily be done by defining a multiFrame SpinnerPattern(), the default speed for custom multiFrame patterns is 0.08, to change with pass a double representing the speed to the init of the Spinner.

let customPattern = SpinnerPattern(multiFrame: ["1","2","3","4","5"])
let mySpinner = Spinner(customPattern, "My Spinner", speed: 0.3, color: .blue)


Many thanks for the 60 plus spinner frames that can be found over at sindresorhus repo built in JavaScript.

You can’t perform that action at this time.