Spectre.Console provides various table border styles to customize the appearance of tables. Each border style defines characters for different parts of the table structure.
Usage Example
var table = new Table();
table.Border(TableBorder.Rounded);
table.AddColumn("Name");
table.AddColumn("Age");
table.AddRow("Alice", "25");
AnsiConsole.Write(table);
Important Notes
- Unicode Support: Some border styles use Unicode box-drawing characters. Ensure your terminal supports Unicode.
- Safe Borders: Each border has a
SafeBorderproperty that provides an ASCII fallback for limited terminals. - Custom Borders: You can create custom borders by inheriting from
TableBorderand implementingGetPart().
Available Table Borders
Total border styles available: 18
TableBorder.Ascii
+-----------------+
| Column1| Column2|
|--------+--------|
| Data | Value |
|--------+--------|
| Data | Value |
|--------+--------|
| Footer | Total |
+-----------------+
TableBorder.Ascii2
+--------+--------+
| Column1| Column2|
|--------+--------|
| Data | Value |
|--------+--------|
| Data | Value |
|--------+--------|
| Footer | Total |
+--------+--------+
TableBorder.AsciiDoubleHead
+--------+--------+
| Column1| Column2|
|========+========|
| Data | Value |
|--------+--------|
| Data | Value |
+--------+--------+
| Footer | Total |
+--------+--------+
TableBorder.Double
╔════════╦════════╗
║ Column1║ Column2║
╠════════╬════════╣
║ Data ║ Value ║
╠════════╬════════╣
║ Data ║ Value ║
╠════════╬════════╣
║ Footer ║ Total ║
╚════════╩════════╝
TableBorder.DoubleEdge
╔════════╤════════╗
║ Column1│ Column2║
╟────────┼────────╢
║ Data │ Value ║
╟────────┼────────╢
║ Data │ Value ║
╟────────┼────────╢
║ Footer │ Total ║
╚════════╧════════╝
TableBorder.Heavy
┏━━━━━━━━┳━━━━━━━━┓
┃ Column1┃ Column2┃
┣━━━━━━━━╋━━━━━━━━┫
┃ Data ┃ Value ┃
┣━━━━━━━━╋━━━━━━━━┫
┃ Data ┃ Value ┃
┣━━━━━━━━╋━━━━━━━━┫
┃ Footer ┃ Total ┃
┗━━━━━━━━┻━━━━━━━━┛
TableBorder.HeavyEdge
┏━━━━━━━━┯━━━━━━━━┓
┃ Column1│ Column2┃
┠────────┼────────┨
┃ Data │ Value ┃
┠────────┼────────┨
┃ Data │ Value ┃
┠────────┼────────┨
┃ Footer │ Total ┃
┗━━━━━━━━┷━━━━━━━━┛
TableBorder.HeavyHead
┏━━━━━━━━┳━━━━━━━━┓
┃ Column1┃ Column2┃
┡━━━━━━━━╇━━━━━━━━┩
│ Data │ Value │
├────────┼────────┤
│ Data │ Value │
├────────┼────────┤
│ Footer │ Total │
└────────┴────────┘
TableBorder.Horizontal
───────────────────
Column1 Column2
───────────────────
Data Value
───────────────────
Data Value
───────────────────
Footer Total
───────────────────
TableBorder.Markdown
| Column1| Column2|
|--------|--------|
| Data | Value |
| Data | Value |
| Footer | Total |
TableBorder.Minimal
Column1│ Column2
────────┼────────
Data │ Value
────────┼────────
Data │ Value
────────┼────────
Footer │ Total
TableBorder.MinimalDoubleHead
Column1│ Column2
════════╪════════
Data │ Value
────────┼────────
Data │ Value
════════╪════════
Footer │ Total
TableBorder.MinimalHeavyHead
Column1│ Column2
━━━━━━━━┿━━━━━━━━
Data │ Value
────────┼────────
Data │ Value
━━━━━━━━┿━━━━━━━━
Footer │ Total
TableBorder.None
Column1 Column2
Data Value
Data Value
Footer Total
TableBorder.Rounded
╭────────┬────────╮
│ Column1│ Column2│
├────────┼────────┤
│ Data │ Value │
├────────┼────────┤
│ Data │ Value │
├────────┼────────┤
│ Footer │ Total │
╰────────┴────────╯
TableBorder.Simple
Column1 Column2
───────────────────
Data Value
───────────────────
Data Value
───────────────────
Footer Total
TableBorder.SimpleHeavy
Column1 Column2
━━━━━━━━━━━━━━━━━━━
Data Value
───────────────────
Data Value
━━━━━━━━━━━━━━━━━━━
Footer Total
TableBorder.Square
┌────────┬────────┐
│ Column1│ Column2│
├────────┼────────┤
│ Data │ Value │
├────────┼────────┤
│ Data │ Value │
├────────┼────────┤
│ Footer │ Total │
└────────┴────────┘