API Reference
Textual
A framework for building interactive terminal user interfaces in Python with reactive widgets.
Official Documentation ↗CompatibilityThis documentation covers version
v8.2.8. Check the official docs for the latest API surface.Installation
pip
pip install textualMethods
No methods match this filter.
Textual composes widgets into a TUI with CSS-like styling and reactive data binding.
Key Features
- Widget composition with CSS styling
- Reactive attributes and messages
- Async workers for background tasks
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The official API reference declares the following error types:
CssPathError(App 构造器 Raises 表中声明的异常) — official text: “|CssPathError| When the supplied CSS path(s) are an unexpected type. |” (source: https://textual.textualize.io/api/app/, fetched 2026-11-08T19:12:00+08:00)NoMatches(组件查询异常(mount 未完成即查询时抛出,官方 guide 记载)) — official text: “you will find that Textual raises a NoMatches exception when you press a key. This is because the mount process has not yet completed when we attempt to change the button.” (source: https://textual.textualize.io/guide/app/, fetched 2026-11-08T19:12:00+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T19:12:00+08:00 via WebFetch https://textual.textualize.io/api/app/(页面在 return_code 属性段被截断,未含方法签名段);WebFetch https://textual.textualize.io/guide/app/.
textual.app.App→ signature from https://textual.textualize.io/api/app/; official text: “App( driver_class=None, css_path=None, watch_css=False, ansi_color=None, ) Bases: Generic[ReturnType], DOMNode The base class for Textual Applications.”App.run→ signature from https://textual.textualize.io/guide/app/; official text: “The addition of[str]tells mypy thatrun()is expected to return a string. It may also returnNoneif App.exit() is called without a return value, so “
FAQ
- How do I handle key presses?
- Define on_key or bind actions with BINDINGS; key handlers are dispatched to the focused widget first.
- Can I run background work?
- Yes. Use run_worker or @work decorated coroutines so the UI stays responsive during IO.
- How does styling work?
- Textual uses CSS-like stylesheets, either inline or in a .tcss file, applied by widget type or id.
Report a problem with this API docOpens a pre-filled issue on GitHub.