The FigletText widget renders text as large ASCII art using FIGlet fonts, creating eye-catching banners and headers.
When to Use
Use FigletText when you need to make text stand out dramatically in console applications. Common scenarios:
- Application branding: Display app names and logos at startup
- Section headers: Create visual separation between major sections
- Status announcements: Highlight important events like "SUCCESS" or "ERROR"
For simple horizontal dividers, use Rule instead. For regular styled text, use Text.
Basic Usage
Create figlet text by passing a string to the constructor. The default font renders clear, readable ASCII art.
var figlet = new FigletText("Hello, World!");
AnsiConsole.Write(figlet);
Styling
Colors
Use the Color() method to match your application's theme or emphasize the message.
var figlet = new FigletText("Spectre")
.Color(Color.Blue);
AnsiConsole.Write(figlet);
Alignment
Centered Text
Use Justification to center figlet text, creating balanced banners and headers.
var figlet = new FigletText("CENTERED")
{
Justification = Justify.Center
};
AnsiConsole.Write(figlet);
All Alignment Options
Control horizontal positioning with left, center, or right alignment.
AnsiConsole.MarkupLine("[yellow]Left alignment (default):[/]");
var leftAligned = new FigletText("LEFT")
{
Justification = Justify.Left
};
AnsiConsole.Write(leftAligned);
AnsiConsole.WriteLine();
AnsiConsole.MarkupLine("[yellow]Center alignment:[/]");
var centerAligned = new FigletText("CENTER")
{
Justification = Justify.Center
};
AnsiConsole.Write(centerAligned);
AnsiConsole.WriteLine();
AnsiConsole.MarkupLine("[yellow]Right alignment:[/]");
var rightAligned = new FigletText("RIGHT")
{
Justification = Justify.Right
};
AnsiConsole.Write(rightAligned);
Custom Fonts
Load custom FIGlet fonts from .flf files to change the appearance. The default font works well for most cases, but custom fonts enable unique branding.
var font = FigletFont.Load("path/to/custom.flf");
var figlet = new FigletText(font, "Custom Font");
AnsiConsole.Write(figlet);
Advanced Usage
Creating Banners
Combine figlet text with rules to create bordered announcements.
var banner = new FigletText("RELEASE v2.0")
{
Color = Color.Green,
Justification = Justify.Center
};
AnsiConsole.Write(new Rule().RuleStyle(Style.Parse("green dim")));
AnsiConsole.Write(banner);
AnsiConsole.Write(new Rule().RuleStyle(Style.Parse("green dim")));
Embedding in Panels
Use panels to add borders and padding around figlet text, perfect for important notifications.
var figlet = new FigletText("SUCCESS")
{
Color = Color.Green,
Justification = Justify.Center
};
var panel = new Panel(figlet)
{
Border = BoxBorder.Double,
BorderStyle = new Style(Color.Green),
Padding = new Padding(1, 1, 1, 1)
};
AnsiConsole.Write(panel);
Welcome Screens
Build multi-line welcome messages by combining figlet text with regular text widgets.
var appName = new FigletText("MyApp")
{
Color = Color.Blue,
Justification = Justify.Center
};
var version = new Text("Version 1.0.0", new Style(Color.Grey))
{
Justification = Justify.Center
};
AnsiConsole.Write(appName);
AnsiConsole.Write(version);
AnsiConsole.WriteLine();
See Also
- Rule Widget - Simple horizontal dividers
- Panel Widget - Wrap figlet text in borders
- Color Reference - Available colors
API Reference
Represents text rendered with a FIGlet font.
Constructors
FigletText(string text)Initializes a new instance of the class.
Parameters:
text (string)FigletText(FigletFont font, string text)Initializes a new instance of the class.
Parameters:
font (FigletFont)text (string)Properties
Color
: Nullable<Color>Gets or sets the color of the text.
Justification
: Nullable<Justify>Pad
: boolGets or sets a value indicating whether or not the right side should be padded.
Extension Methods
FigletText Color(Nullable<Color> color)Sets the color of the FIGlet text.
Parameters:
color (Nullable<Color>)Returns:
The same instance so that multiple calls can be chained.
IEnumerable<Segment> GetSegments(IAnsiConsole console)Gets the segments for a renderable using the specified console.
Parameters:
console (IAnsiConsole)Returns:
An enumerable containing segments representing the specified .