Skip to main content
The LineNumberRenderable component displays line numbers and custom signs alongside text components that implement LineInfoProvider. It’s commonly used with code editors, file viewers, and diff displays.

Basic Usage

Props

Renderable & LineInfoProvider
required
The text component to display line numbers for. Must implement the LineInfoProvider interface (e.g., TextBufferRenderable, EditBufferRenderable, CodeRenderable).
string | RGBA
Default foreground color for line numbers. Defaults to terminal foreground color.
string | RGBA
Default background color for the gutter. Defaults to transparent.
number
Minimum width in characters for the line number column. Automatically expands for larger line numbers. Default: 0.
number
Padding between line numbers and the text content in characters. Default: 1.
Map<number, string | RGBA | LineColorConfig>
Custom colors for specific lines. Can set gutter color, content color, or both:
Map<number, LineSign>
Custom signs/icons to display for specific lines:
number
Offset to add to line numbers. Useful for displaying subset of a larger file. Default: 0.
Set<number>
Set of line numbers to hide. The gutter space remains but the number is not displayed.
Map<number, number>
Custom mapping to override displayed line numbers. Maps actual line index to displayed number.
boolean
Whether to show line numbers at all. When false, only signs are displayed. Default: true.

Types

LineSign

LineColorConfig

Examples

Git-style diff indicators

Error and warning indicators

Highlight current line

Breakpoint markers (debugger)

Custom line numbering

Relative line numbers (Vim-style)

Common Patterns

Code editor with line numbers

Dynamic sign updates

Notes

The target component must implement the LineInfoProvider interface, which includes CodeRenderable, TextBufferRenderable, EditBufferRenderable, InputRenderable, and TextareaRenderable.
LineNumberRenderable automatically adjusts its width based on the number of digits in line numbers. The minWidth prop ensures a minimum width even for small line counts.
Use lineColors to highlight the current line, errors, or other special lines. Combine with lineSigns for visual indicators like breakpoints or git changes.
  • Code - Syntax-highlighted code display
  • Diff - Side-by-side or unified diff viewer
  • Textarea - Multi-line text editor