# rivo/tview architecture

> Architecture diagram of the GitHub repository rivo/tview, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rivo/tview
- Repository: https://github.com/rivo/tview

## Overview

tview is a Go library for building interactive terminal user interfaces. A caller constructs an application, assigns a root primitive, and runs it; the application manages terminal interaction and renders the primitive hierarchy. The library provides layout containers, interactive controls, and navigable or visual content widgets. The README documents these major capabilities, while sampled source confirms a few internal compositions, including inputs built on text areas and dropdowns using lists. Many widget-to-widget relationships are not evidenced by the excerpts, so those links are omitted.

Main entry points: [`application.go`](https://github.com/rivo/tview/blob/master/application.go) (Application), [`form.go`](https://github.com/rivo/tview/blob/master/form.go) (Input forms), [`dropdown.go`](https://github.com/rivo/tview/blob/master/dropdown.go) (Dropdown selection), [`inputfield.go`](https://github.com/rivo/tview/blob/master/inputfield.go) (Text input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_application["Application<br/>[application.go]"]
end

subgraph group_layout["Layout containers"]
  node_box["Box primitive<br/>[box.go]"]
  node_flex["Flex layout<br/>[flex.go]"]
  node_grid["Grid layout<br/>[grid.go]"]
  node_frame["Frame layout<br/>[frame.go]"]
  node_pages["Pages layout<br/>[pages.go]"]
end

subgraph group_controls["Interactive controls"]
  node_form["Input forms<br/>[form.go]"]
  node_input["Text input<br/>[inputfield.go]"]
  node_textarea["Text area<br/>[textarea.go]"]
  node_dropdown["Dropdown selection<br/>[dropdown.go]"]
  node_checkbox["Checkbox<br/>[checkbox.go]"]
  node_button["Button<br/>[button.go]"]
  node_modal["Modal window<br/>[modal.go]"]
end

subgraph group_content["Content widgets"]
  node_textview["Navigable text<br/>[textview.go]"]
  node_table["Table view<br/>[table.go]"]
  node_treeview["Tree view<br/>[treeview.go]"]
  node_list["Selectable list<br/>[list.go]"]
  node_image["Image display<br/>[image.go]"]
  node_semigraphics["Semigraphics<br/>[semigraphics.go]"]
  node_ansi["ANSI support<br/>[ansi.go]"]
  node_strings["Text utilities<br/>[strings.go]"]
end

node_caller(("TUI caller"))
node_terminal["Terminal screen"]

node_caller -->|"creates and runs"| node_application
node_caller -->|"sets root"| node_box
node_application -->|"uses screen"| node_terminal
node_application -.->|"renders root"| node_box
node_input -->|"delegates editing"| node_textarea
node_dropdown -->|"draws options"| node_list
node_dropdown -->|"uses prefix input"| node_input
node_form -->|"creates buttons"| node_button
node_form -.->|"supports text areas"| node_textarea

click node_application "https://github.com/rivo/tview/blob/master/application.go"
click node_box "https://github.com/rivo/tview/blob/master/box.go"
click node_flex "https://github.com/rivo/tview/blob/master/flex.go"
click node_grid "https://github.com/rivo/tview/blob/master/grid.go"
click node_frame "https://github.com/rivo/tview/blob/master/frame.go"
click node_pages "https://github.com/rivo/tview/blob/master/pages.go"
click node_form "https://github.com/rivo/tview/blob/master/form.go"
click node_input "https://github.com/rivo/tview/blob/master/inputfield.go"
click node_textarea "https://github.com/rivo/tview/blob/master/textarea.go"
click node_dropdown "https://github.com/rivo/tview/blob/master/dropdown.go"
click node_checkbox "https://github.com/rivo/tview/blob/master/checkbox.go"
click node_button "https://github.com/rivo/tview/blob/master/button.go"
click node_modal "https://github.com/rivo/tview/blob/master/modal.go"
click node_textview "https://github.com/rivo/tview/blob/master/textview.go"
click node_table "https://github.com/rivo/tview/blob/master/table.go"
click node_treeview "https://github.com/rivo/tview/blob/master/treeview.go"
click node_list "https://github.com/rivo/tview/blob/master/list.go"
click node_image "https://github.com/rivo/tview/blob/master/image.go"
click node_semigraphics "https://github.com/rivo/tview/blob/master/semigraphics.go"
click node_ansi "https://github.com/rivo/tview/blob/master/ansi.go"
click node_strings "https://github.com/rivo/tview/blob/master/strings.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_application,node_caller,node_terminal toneBlue
class node_box,node_flex,node_grid,node_frame,node_pages toneAmber
class node_form,node_input,node_textarea,node_dropdown,node_checkbox,node_button,node_modal toneMint
class node_textview,node_table,node_treeview,node_list,node_image,node_semigraphics,node_ansi,node_strings toneRose
```

## Components

### Application runtime

- [Application](https://github.com/rivo/tview/blob/master/application.go): `application.go`

### Layout containers

- [Box primitive](https://github.com/rivo/tview/blob/master/box.go): `box.go`
- [Flex layout](https://github.com/rivo/tview/blob/master/flex.go): `flex.go`
- [Grid layout](https://github.com/rivo/tview/blob/master/grid.go): `grid.go`
- [Frame layout](https://github.com/rivo/tview/blob/master/frame.go): `frame.go`
- [Pages layout](https://github.com/rivo/tview/blob/master/pages.go): `pages.go`

### Interactive controls

- [Input forms](https://github.com/rivo/tview/blob/master/form.go): `form.go`
- [Text input](https://github.com/rivo/tview/blob/master/inputfield.go): `inputfield.go`
- [Text area](https://github.com/rivo/tview/blob/master/textarea.go): `textarea.go`
- [Dropdown selection](https://github.com/rivo/tview/blob/master/dropdown.go): `dropdown.go`
- [Checkbox](https://github.com/rivo/tview/blob/master/checkbox.go): `checkbox.go`
- [Button](https://github.com/rivo/tview/blob/master/button.go): `button.go`
- [Modal window](https://github.com/rivo/tview/blob/master/modal.go): `modal.go`

### Content widgets

- [Navigable text](https://github.com/rivo/tview/blob/master/textview.go): `textview.go`
- [Table view](https://github.com/rivo/tview/blob/master/table.go): `table.go`
- [Tree view](https://github.com/rivo/tview/blob/master/treeview.go): `treeview.go`
- [Selectable list](https://github.com/rivo/tview/blob/master/list.go): `list.go`
- [Image display](https://github.com/rivo/tview/blob/master/image.go): `image.go`
- [Semigraphics](https://github.com/rivo/tview/blob/master/semigraphics.go): `semigraphics.go`
- [ANSI support](https://github.com/rivo/tview/blob/master/ansi.go): `ansi.go`
- [Text utilities](https://github.com/rivo/tview/blob/master/strings.go): `strings.go`

### Other components

- **TUI caller**
- **Terminal screen**

## Connections

- TUI caller → Application: creates and runs (evidence: `README.md`)
- TUI caller → Box primitive: sets root (evidence: `README.md`)
- Application → Terminal screen: uses screen (evidence: `application.go`)
- Application → Box primitive: renders root
- Text input → Text area: delegates editing (evidence: `inputfield.go`)
- Dropdown selection → Selectable list: draws options (evidence: `dropdown.go`)
- Dropdown selection → Text input: uses prefix input (evidence: `dropdown.go`)
- Input forms → Button: creates buttons (evidence: `form.go`)
- Input forms → Text area: supports text areas
