Status Display

Show animated status indicators with spinners for ongoing operations

The Status display renders an animated spinner with a status message for long-running operations.

Screenshot

When to Use

Use Status when you need to indicate ongoing work without tracking specific progress. Common scenarios:

  • Indeterminate operations: Show activity when duration or completion percentage is unknown
  • Connection attempts: Display feedback while connecting to services or loading resources
  • Background processing: Indicate that work is happening behind the scenes

For operations with measurable progress (file downloads, batch processing), use Progress instead.

Caution

Status display is not thread safe. Using it together with other interactive components such as prompts, progress displays, or other status displays is not supported.

Basic Usage

Create a status display by calling AnsiConsole.Status().Start() with a message and a callback containing your work.

csharp
AnsiConsole.Status()
    .Start("Processing data...", ctx =>
    {
        // Simulate work
        Thread.Sleep(3000);
  
        AnsiConsole.MarkupLine("[green]Processing complete![/]");
    });

Spinners

Choosing a Spinner

Select a spinner animation that matches your application's style or the type of operation being performed.

csharp
AnsiConsole.Status()
    .Spinner(Spinner.Known.Star)
    .Start("Loading resources...", ctx =>
    {
        Thread.Sleep(2000);
        AnsiConsole.MarkupLine("[green]Resources loaded![/]");
    });

Note

See the Spinner Reference for a gallery of all available spinner animations.

Styling the Spinner

Apply colors and styles to the spinner to convey meaning or match your application's theme.

csharp
AnsiConsole.Status()
    .Spinner(Spinner.Known.Dots)
    .SpinnerStyle(Style.Parse("bold yellow"))
    .Start("Connecting to server...", ctx =>
    {
        Thread.Sleep(2500);
        AnsiConsole.MarkupLine("[green]Connected successfully![/]");
    });

Async Operations

Use StartAsync() when working with asynchronous code to avoid blocking the UI thread.

csharp
await AnsiConsole.Status()
    .StartAsync("Downloading files...", async ctx =>
    {
        // Simulate async work
        await Task.Delay(3000);
  
        AnsiConsole.MarkupLine("[green]Download complete![/]");
    });

Returning Values

Status operations can return values from the callback, allowing you to retrieve results after completion.

csharp
var result = AnsiConsole.Status()
    .Start("Calculating results...", ctx =>
    {
        // Simulate calculation
        Thread.Sleep(2000);
  
        return 42;
    });
  
AnsiConsole.MarkupLine($"[green]Result: {result}[/]");

Dynamic Updates

Changing Status Text

Update the status message as your operation progresses through different stages.

csharp
AnsiConsole.Status()
    .Start("Starting process...", ctx =>
    {
        ctx.Status("Loading configuration...");
        Thread.Sleep(1000);
  
        ctx.Status("Connecting to database...");
        Thread.Sleep(1500);
  
        ctx.Status("Fetching data...");
        Thread.Sleep(1000);
  
        ctx.Status("Processing records...");
        Thread.Sleep(1500);
  
        AnsiConsole.MarkupLine("[green]All tasks completed![/]");
    });

Changing the Spinner

Switch spinner animations at runtime to indicate different types of activity.

csharp
AnsiConsole.Status()
    .Start("Initializing...", ctx =>
    {
        ctx.Status("Starting services...");
        ctx.Spinner(Spinner.Known.Dots);
        Thread.Sleep(1500);
  
        ctx.Status("Loading modules...");
        ctx.Spinner(Spinner.Known.Line);
        Thread.Sleep(1500);
  
        ctx.Status("Running diagnostics...");
        ctx.Spinner(Spinner.Known.BouncingBar);
        Thread.Sleep(1500);
  
        ctx.Status("Finalizing...");
        ctx.Spinner(Spinner.Known.Star);
        Thread.Sleep(1000);
  
        AnsiConsole.MarkupLine("[green]System ready![/]");
    });

Manual Refresh

Disable automatic refresh when you need precise control over when the status display updates.

csharp
AnsiConsole.Status()
    .AutoRefresh(false)
    .Start("Processing batch...", ctx =>
    {
        for (int i = 1; i <= 5; i++)
        {
            ctx.Status($"Processing item {i} of 5...");
            ctx.Refresh();
  
            Thread.Sleep(800);
  
            AnsiConsole.MarkupLine($"[grey]Item {i} processed[/]");
        }
  
        AnsiConsole.MarkupLine("[green]Batch complete![/]");
    });

Markup Support

Use Spectre.Console's markup syntax in status text to add colors, styles, and emphasis.

csharp
AnsiConsole.Status()
    .Spinner(Spinner.Known.Dots)
    .Start("[yellow]Initializing[/]...", ctx =>
    {
        Thread.Sleep(1000);
  
        ctx.Status("[blue]Connecting to [bold]API server[/][/]...");
        Thread.Sleep(1500);
  
        ctx.Status("[cyan]Authenticating user[/]...");
        Thread.Sleep(1000);
  
        ctx.Status("[green]Loading [italic]user preferences[/][/]...");
        Thread.Sleep(1500);
  
        AnsiConsole.MarkupLine("[bold green]Startup complete![/]");
    });

See Also

API Reference

Represents a status display.

Constructors

public Status(IAnsiConsole console)

Initializes a new instance of the Status class.

Parameters:

console (IAnsiConsole)
The console.

Properties

AutoRefresh : bool

Gets or sets a value indicating whether or not status should auto refresh. Defaults to true.

Spinner : Spinner

Gets or sets the spinner.

Methods

public void Start(string status, Action<StatusContext> action)

Starts a new status display.

Parameters:

status (string)
The status to display.
action (Action<StatusContext>)
The action to execute.
public T Start<T>(string status, Func<StatusContext, T> func)

Starts a new status display.

Parameters:

status (string)
The status to display.
func (Func<StatusContext, T>)
The action to execute.

Returns:

The result.

public Task StartAsync(string status, Func<StatusContext, Task> action)

Starts a new status display.

Parameters:

status (string)
The status to display.
action (Func<StatusContext, Task>)
The action to execute.

Returns:

A Task representing the asynchronous operation.

public Task<T> StartAsync<T>(string status, Func<StatusContext, Task<T>> func)

Starts a new status display and returns a result.

Parameters:

status (string)
The status to display.
func (Func<StatusContext, Task<T>>)
The action to execute.

Returns:

A Task representing the asynchronous operation.

Extension Methods

Status AutoRefresh(this Status status, bool enabled)

Sets whether or not auto refresh is enabled. If disabled, you will manually have to refresh the progress.

Returns:

The same instance so that multiple calls can be chained.

Status Spinner(this Status status, Spinner spinner)

Sets the spinner.

Returns:

The same instance so that multiple calls can be chained.