textual-data-display
Display structured data in Textual using tables, lists, trees, and scrollable containers. Use when rendering data tables, building list views, displaying hierarchical data, scrolling large content, pagination, and efficient rendering of large datasets. Covers DataTable, ListView, Tree, and scrolling patterns.
What this skill does
# Textual Data Display
## Purpose
Efficiently display and interact with structured data using Textual's data widgets. These widgets handle selection, scrolling, and large datasets with excellent performance.
## Quick Start
```python
from textual.widgets import DataTable, Static
from textual.app import ComposeResult
class TableWidget(Static):
"""Display data in a table."""
def compose(self) -> ComposeResult:
yield DataTable()
async def on_mount(self) -> None:
"""Initialize table with data."""
table = self.query_one(DataTable)
# Add columns
table.add_column("Name", key="name")
table.add_column("Status", key="status")
table.add_column("CPU %", key="cpu")
# Add rows
table.add_row("Agent-1", "Running", "45.2", key="agent-1")
table.add_row("Agent-2", "Idle", "12.5", key="agent-2")
table.add_row("Agent-3", "Running", "78.9", key="agent-3")
```
## Instructions
### Step 1: Use DataTable for Tabular Data
DataTable is the most powerful widget for structured data:
```python
from textual.widgets import DataTable
from textual.app import ComposeResult
from typing import Callable
class DataTableWidget(Static):
"""Widget for displaying tabular data."""
def compose(self) -> ComposeResult:
yield DataTable(id="data-table")
async def on_mount(self) -> None:
"""Initialize table."""
table = self.query_one("#data-table", DataTable)
# Configure table
table.show_header = True # Show column headers
table.show_row_labels = True # Show row numbers
table.fixed_rows = 1 # Fix header row
# Add columns with optional width
table.add_column("ID", key="id", width=8)
table.add_column("Name", key="name", width=20)
table.add_column("Status", key="status", width=15)
table.add_column("Updated", key="updated", width=20)
# Add rows
data = [
("1", "Agent-1", "Running", "2024-01-15 10:30:45"),
("2", "Agent-2", "Idle", "2024-01-15 09:15:20"),
("3", "Agent-3", "Error", "2024-01-15 08:45:10"),
]
for row_data in data:
table.add_row(*row_data, key=row_data[0])
async def get_selected_row(self) -> tuple | None:
"""Get currently selected row data.
Returns:
Tuple of row values or None if no selection.
"""
table = self.query_one("#data-table", DataTable)
if table.cursor_row is not None:
row_key = table.cursor_row
row = table.get_row(row_key)
return row if row else None
return None
async def clear_table(self) -> None:
"""Clear all data rows (keeps header)."""
table = self.query_one("#data-table", DataTable)
table.clear()
async def add_row(self, *values: str, key: str | None = None) -> None:
"""Add a row to table."""
table = self.query_one("#data-table", DataTable)
table.add_row(*values, key=key)
async def update_row(self, row_key: str, *values: str) -> None:
"""Update existing row."""
table = self.query_one("#data-table", DataTable)
table.update_row(row_key, *values)
```
**DataTable Features:**
- Columns with optional widths and keys
- Row keys for easy lookup
- Cursor movement (up/down arrows)
- Single/multiple selection modes
- Sortable columns
- Fixed header rows
- Efficient rendering of large datasets
### Step 2: Handle DataTable Selection Events
Respond to user interactions:
```python
from textual.widgets import DataTable, Static
from textual import on
class SelectableTableWidget(Static):
"""Table with selection handling."""
def compose(self) -> ComposeResult:
yield DataTable(id="table")
async def on_mount(self) -> None:
"""Initialize table."""
table = self.query_one("#table", DataTable)
table.add_column("Item")
table.add_column("Value")
for i in range(5):
table.add_row(f"Item {i}", f"Value {i}", key=str(i))
@on(DataTable.RowSelected)
async def on_row_selected(self, event: DataTable.RowSelected) -> None:
"""Handle row selection."""
row_key = event.cursor_row
table = self.query_one("#table", DataTable)
# Get row data
row_data = table.get_row(row_key)
self.app.notify(f"Selected: {row_data}")
@on(DataTable.RowHighlighted)
async def on_row_highlighted(self, event: DataTable.RowHighlighted) -> None:
"""Called as cursor moves (preview)."""
row_key = event.cursor_row
# Can use for hovering effects
@on(DataTable.CellSelected)
async def on_cell_selected(self, event: DataTable.CellSelected) -> None:
"""Handle specific cell selection."""
row_key = event.cursor_row
column_key = event.cursor_column
```
**DataTable Events:**
- `RowSelected` - Row clicked/selected
- `RowHighlighted` - Row cursor moved over
- `CellSelected` - Specific cell selected
- `CellHighlighted` - Cell cursor moved over
### Step 3: Use ListView for Simple Lists
For simple lists with less overhead:
```python
from textual.widgets import ListView, ListItem, Static
from textual.app import ComposeResult
from textual import on
class ListViewWidget(Static):
"""Simple list view."""
def compose(self) -> ComposeResult:
yield ListView(id="list")
async def on_mount(self) -> None:
"""Populate list."""
list_view = self.query_one("#list", ListView)
items = ["Item 1", "Item 2", "Item 3", "Item 4"]
for item_text in items:
await list_view.append(
ListItem(Static(item_text))
)
@on(ListView.Selected)
async def on_item_selected(self, event: ListView.Selected) -> None:
"""Handle item selection."""
selected_item = event.item
index = event.selection_index
self.app.notify(f"Selected item {index}")
async def get_selected(self) -> str | None:
"""Get selected item."""
list_view = self.query_one("#list", ListView)
if list_view.index is not None:
item = list(list_view.children)[list_view.index]
if isinstance(item, ListItem):
# Extract text from ListItem
child = list(item.children)[0]
if isinstance(child, Static):
return child.render_str()
return None
```
**ListView vs DataTable:**
- `ListView` - Simpler, lighter weight, for lists of items
- `DataTable` - More powerful, columnar data, selection handling
### Step 4: Use Tree for Hierarchical Data
Display tree/nested structures:
```python
from textual.widgets import Tree, Static
from textual.app import ComposeResult
from textual import on
class TreeWidget(Static):
"""Display hierarchical data."""
def compose(self) -> ComposeResult:
tree = Tree("Root")
tree.root.expand()
# Add branches
agents_branch = tree.root.add("Agents")
agents_branch.add("Agent-1")
agents_branch.add("Agent-2")
agents_branch.add("Agent-3")
settings_branch = tree.root.add("Settings")
settings_branch.add("General")
settings_branch.add("Advanced")
settings_branch.add("About")
yield tree
@on(Tree.NodeSelected)
async def on_node_selected(self, event: Tree.NodeSelected) -> None:
"""Handle node selection."""
node = event.node
label = node.label
self.app.notify(f"Selected: {label}")
@on(Tree.NodeExpanded)
async def on_node_expanded(self, event: Tree.NodeExpanded) -> None:
"""Handle node expansion."""
node = event.node
# Load children on demand
pass
@on(Tree.NodeCollapsed)
async def on_node_collapsed(self, event: Tree.NodeCollapsed) -> None:
"""Handle node collapse."""
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.