Skip to content

CursorLine

Renders a single line of text with a visible cursor at a split point. Extracts the duplicated cursor-rendering pattern into a reusable primitive.

Import

tsx
import { CursorLine } from "silvery"

Props

PropTypeDefaultDescription
beforeCursorstringrequiredText before the cursor position
afterCursorstringrequiredText after the cursor position (first char gets cursor highlight)
colorstring--Text color
showCursorbooleantrueWhether to show the cursor
cursorStyle"block" | "underline""block"Cursor style
onCursorClick(offset: number) => void--Called when clicked, provides character offset

Behavior

The cursor character is afterCursor[0] (or a space when afterCursor is empty, indicating cursor at end of text). The character is rendered with inverse video (block) or underline styling.

Usage

tsx
<CursorLine beforeCursor="hel" afterCursor="lo world" />
<CursorLine beforeCursor="full text" afterCursor="" />
<CursorLine beforeCursor="" afterCursor="start" cursorStyle="underline" />

See Also

Released under the MIT License.