@@ -442,28 +442,38 @@ function paintTextInput(
442442 const { x, y, width: w, height: h } = rect;
443443 if (w <= 0 || h <= 0) return;
444444
445+ // Apply padding — content is inset from the rect edges
446+ const padX = props.padding?.x ?? 0;
447+ const padY = props.padding?.y ?? 0;
448+ const cx = x + padX;
449+ const cy = y + padY;
450+ const cw = Math.max(0, w - padX * 2);
451+ const ch = Math.max(0, h - padY * 2);
452+ if (cw <= 0 || ch <= 0) return;
453+
445454 const value = props.value;
446455 const showPlaceholder = value.length === 0 && props.placeholder;
447456
448457 if (showPlaceholder && props.placeholder) {
449- // Paint placeholder text
458+ // Paint placeholder text in padded content area
459+ const contentRect: Rect = { x: cx, y: cy, width: cw, height: ch };
450460 paintText(
451461 props.placeholder.content,
452462 props.placeholder.props,
453- rect,
463+ contentRect,
454464 clipRect,
455465 buf,
456466 );
457467 return;
458468 }
459469
460- // Word-wrap value (always on for TextInput)
470+ // Word-wrap value (always on for TextInput) using content width
461471 const lines: string[] = [];
462472 for (const rawLine of value.split("\n")) {
463- if (visibleWidth(rawLine) <= w) {
473+ if (visibleWidth(rawLine) <= cw) {
464474 lines.push(rawLine);
465475 } else {
466- wrapLine(rawLine, w, lines);
476+ wrapLine(rawLine, cw, lines);
467477 }
468478 }
469479
@@ -472,10 +482,10 @@ function paintTextInput(
472482
473483 if (props.focused) {
474484 const cursorOffset = getTextInputCursor(props);
475- const cursorPos = offsetToWrappedPos(value, cursorOffset, w);
485+ const cursorPos = offsetToWrappedPos(value, cursorOffset, cw);
476486 // Scroll down if cursor is below viewport
477- if (cursorPos.line >= scrollOffset + h) {
478- scrollOffset = cursorPos.line - h + 1;
487+ if (cursorPos.line >= scrollOffset + ch) {
488+ scrollOffset = cursorPos.line - ch + 1;
479489 }
480490 // Scroll up if cursor is above viewport
481491 if (cursorPos.line < scrollOffset) {
@@ -484,23 +494,23 @@ function paintTextInput(
484494 setTextInputScroll(props, scrollOffset);
485495 }
486496
487- // Paint visible lines (grapheme-aware)
488- for (let row = 0; row < h; row++) {
497+ // Paint visible lines (grapheme-aware) in content area
498+ for (let row = 0; row < ch; row++) {
489499 const lineIdx = scrollOffset + row;
490500 if (lineIdx >= lines.length) break;
491501 const line = lines[lineIdx]!;
492- paintLineGraphemes(line, x, y + row, w, clipRect, props, buf);
502+ paintLineGraphemes(line, cx, cy + row, cw, clipRect, props, buf);
493503 }
494504
495505 // Paint cursor if focused
496506 if (props.focused) {
497507 const cursorOffset = getTextInputCursor(props);
498- const pos = offsetToWrappedPos(value, cursorOffset, w);
508+ const pos = offsetToWrappedPos(value, cursorOffset, cw);
499509 const screenRow = pos.line - scrollOffset;
500- if (screenRow >= 0 && screenRow < h && pos.col < w) {
501- const existing = buf.get(x + pos.col, y + screenRow);
510+ if (screenRow >= 0 && screenRow < ch && pos.col < cw) {
511+ const existing = buf.get(cx + pos.col, cy + screenRow);
502512 // Invert colors for cursor visibility
503- buf.set(x + pos.col, y + screenRow, {
513+ buf.set(cx + pos.col, cy + screenRow, {
504514 char: existing.char === " " && !existing.bgColor ? " " : existing.char,
505515 fgColor: existing.bgColor ?? "black",
506516 bgColor: existing.fgColor ?? "white",