🎯 What is RazorConsole?
RazorConsole bridges the gap between modern web UI development and console applications. It lets you create sophisticated terminal interfaces using Razor components, complete with interactive elements, rich styling, and familiar development patterns.
📦 Install
dotnet add package RazorConsole.Core
🚀 Usage
Project Setup
RazorConsole requires the Microsoft.NET.Sdk.Razor SDK to compile Razor components. Update your project file (.csproj) to use the Razor SDK:
<Project Sdk="Microsoft.NET.Sdk.Razor">
<!-- other settings -->
</Project>
Basic Example
Here's a simple counter component to get you started:
Counter.razor
@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Web
@using RazorConsole.Components
<Columns>
<p>Current count</p>
<Markup Content="@currentCount.ToString()" Foreground="@Spectre.Console.Color.Green" />
</Columns>
<TextButton Content="Click me"
OnClick="IncrementCount"
BackgroundColor="@Spectre.Console.Color.Grey"
FocusedColor="@Spectre.Console.Color.Blue" />
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
Program.cs
using Microsoft.Extensions.Hosting;
using RazorConsole.Core;
IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args)
.UseRazorConsole<Counter>();
IHost host = hostBuilder.Build();
await host.RunAsync();

For more complete sample applications, check out the Examples section below.
Rendering pipeline
RazorConsole renders every frame through WidgetLayout: components become widgets
that are measured, arranged and painted into terminal cells, which gives every
element known bounds for focus, layout queries and coordinate-aware mouse events.
Spectre.Console-backed content such as charts, Figlet text and syntax highlighting
is painted as widget leaves.
The legacy Spectre.Console layout pipeline was removed in 1.0 (earlier warnings
said 1.1.0). If you upgrade from 0.x, remove any ConsoleAppOptions.RenderingPipeline
assignment and the RAZORCONSOLE_RENDERING_PIPELINE environment variable, which
no longer has any effect, and move custom ITranslationMiddleware translators to
IWidgetTranslator. ConsoleAppOptions.AfterRenderAsync was also removed; use the
root component's OnAfterRenderAsync, IHostApplicationLifetime.ApplicationStarted
or an IHostedService instead. ConsoleViewResult, ConsoleLiveDisplayContext and
FocusManager.BeginSession are now internal. See the
Widget Layout guide and the
custom translator guide for details.