In this tutorial, we'll build a coffee brewing simulation that shows animated spinners while work happens. By the end, you'll know how to display status messages, update them as work progresses, and customize the spinner style.
What We're Building
Here's what our coffee brewing simulation will look like:
Prerequisites
- .NET 6.0 or later
- Basic C# knowledge
- Completion of the Getting Started tutorial
- 1
Show a Basic Spinner
Let's start by showing a spinner while our "coffee grinder" runs. The
Status()method displays an animated spinner with a message:public void ShowBasicSpinner() { AnsiConsole.Status() .Start("Grinding beans...", ctx => { // Simulate grinding Thread.Sleep(3000); }); AnsiConsole.MarkupLine("[green]Done![/]"); }Run the code:
dotnet runYou should see an animated spinner next to "Grinding beans..." that runs for a few seconds, then "Done!" appears.
Notice how the spinner animates automatically? Spectre.Console handles the animation loop for you - just put your work inside the callback.
That's your first status spinner.
- 2
Update the Status Text
Real tasks have multiple stages. Let's update the status message as our coffee progresses through grinding, brewing, and pouring:
public void UpdateStatusText() { AnsiConsole.Status() .Start("Grinding beans...", ctx => { Thread.Sleep(1500); ctx.Status("Brewing coffee..."); Thread.Sleep(2000); ctx.Status("Pouring into cup..."); Thread.Sleep(1000); }); AnsiConsole.MarkupLine("[green]Coffee is ready![/]"); }Run it:
dotnet runYou should see the message change from "Grinding beans..." to "Brewing coffee..." to "Pouring into cup..." - all while the spinner keeps animating.
Notice how we use
ctx.Status()to change the message? Thectxparameter gives you control over the status display while it's running.Your status now reflects what's actually happening.
- 3
Try Different Spinners
Spectre.Console includes many spinner styles. Let's try a few to see the difference:
public void TryDifferentSpinners() { // Calm and steady AnsiConsole.Status() .Spinner(Spinner.Known.Dots) .Start("Grinding beans...", ctx => { Thread.Sleep(2000); }); // Energetic AnsiConsole.Status() .Spinner(Spinner.Known.Star) .SpinnerStyle(Style.Parse("yellow")) .Start("Brewing coffee...", ctx => { Thread.Sleep(2000); }); AnsiConsole.MarkupLine("[green]Done![/]"); }Run it:
dotnet runYou should see two different spinner animations - the smooth
Dotsspinner for grinding, then the livelyStarspinner (in yellow) for brewing.Notice how
.Spinner()sets the style and.SpinnerStyle()sets the color? You can match the spinner to your app's personality.You can now customize the look and feel of your spinners.
- 4
Complete Coffee Brew
Let's put it all together into a complete brewing experience that changes both the message and spinner style at each stage:
// Error: Symbol not found: M:Spectre.Docs.Examples.SpectreConsole.Tutorials.StatusSpinnersTutorial.ShowCompleteCoffeeBrew for 'M:Spectre.Docs.Examples.SpectreConsole.Tutorials.StatusSpinnersTutorial.ShowCompleteCoffeeBrew'Run the complete application:
dotnet runYou should see "Time for coffee!" followed by an animated brewing sequence: yellow dots while grinding, blue stars while brewing, and a green arc while pouring - then the final success message.
Notice how we change both the spinner and its color using
ctx.Spinner()andctx.SpinnerStyle()? This creates a dynamic, engaging experience.That's a polished status display with some personality.
Congratulations!
We've built a coffee brewing simulation that demonstrates all the core status features. Our application shows animated spinners, updates messages as work progresses, and customizes the spinner style to match each stage.
These same techniques work for any long-running operation: file uploads, API calls, database queries, build processes, and more.
Next Steps
- Showing Progress Bars - Track multiple operations with progress bars
- Status Reference - Explore async operations, return values, and manual refresh
- Spinner Reference - See all available spinner styles