Skip to content

Image

const Image: ForwardRefExoticComponent<ImageProps & RefAttributes<ImageHandle>>;

Inline image for terminal UIs.

Displays a placeholder until the user presses Space (or set autoLoad). Supports Kitty and iTerm2 graphics protocols for true inline rendering, with fallback to OS-level preview. Press Escape to unload.

<Image src="./logo.png" width={40} height={12} />
// Auto-load with auto-size
<Image
src="https://example.com/photo.jpg"
autoLoad
autoSize
maxWidth={60}
maxHeight={20}
/>

PropertyTypeDescription
autoLoad?booleanAuto-load on mount (default: false - user presses space)
autoSize?booleanAuto-size the box to fit the image dimensions (default: false). When true, the box resizes to match the image’s aspect ratio. Use maxWidth/maxHeight to constrain the size.
disabled?booleanWhether the component is disabled (skipped in tab order, no key handling)
focusable?booleanWhether the component is focusable (default: true)
focusedStyle?StyleStyle when focused
height?numberFixed height in cells (optional, uses flexbox if not set)
inline?booleanAllow inline rendering in terminal (default: true)
maxHeight?numberMaximum height in cells when autoSize is true
maxWidth?numberMaximum width in cells when autoSize is true
onError?(error) => voidCalled on error
onStateChange?(state) => voidCalled when image state changes
placeholder?stringCustom placeholder text (default: image name)
placeholderStyle?StyleStyle for the placeholder
srcstringImage source - local path or remote URL
style?StyleContainer style (flexbox)
unloadTrigger?numberForce unload trigger - increment this value to force the image to unload. Useful when parent component handles Escape or other close actions. Example: <Image unloadTrigger={unloadCount} … />
width?numberFixed width in cells (optional, uses flexbox if not set)

type ImageState = "placeholder" | "loading" | "loaded" | "error" | "preview";

Lifecycle state of the Image component.

  • "placeholder" — waiting for user to press Space to load
  • "loading" — image data is being fetched / decoded
  • "loaded" — rendered inline via Kitty / iTerm2 protocol
  • "error" — loading failed
  • "preview" — opened via OS-level preview (Quick Look / xdg-open)

Handle for Image

blur(): void;

Programmatically blur (unfocus) this element

void

FocusableHandle.blur


focus(): void;

Programmatically focus this element

void

FocusableHandle.focus


scrollIntoView(options?): void;

Scroll the nearest parent ScrollView to make this element visible. Behaves like the DOM Element.scrollIntoView() method. No-op if the element is not inside a ScrollView.

ParameterTypeDescription
options?ScrollIntoViewOptionsAlignment options (default: { block: "nearest" })

void

const inputRef = useRef<InputHandle>(null);
// Minimal scroll — just enough to make it visible
inputRef.current?.scrollIntoView();
// Center the element in the viewport
inputRef.current?.scrollIntoView({ block: "center" });

FocusableHandle.scrollIntoView

PropertyModifierTypeDescriptionInherited from
isFocusedreadonlybooleanWhether this element is currently focusedFocusableHandle.isFocused