Quick Start
Welcome to the Kite documentation! This page introduces the core concepts you will use in almost every terminal application.
- How to create and nest Kitex components
- How to style elements with
style.S()and pseudo-states - How to respond to keyboard and mouse events and update state
- How to render keyed lists and conditional UI
- When to add shared state (
kites), async data (wind), or screens (flight)
Creating and nesting components
Section titled “Creating and nesting components”Kite applications are built from components—reusable pieces of terminal UI that manage their own appearance and logic. With extras/kitex, define a component using kitex.FC (leaf component) or kitex.FCC (container accepting children).
Adding state and interactivity
Section titled “Adding state and interactivity”Call kitex.UseState inside a component to remember state across renders. Combine it with style.S() pseudo-states (.Hover(...), .Focus(...), .Active(...)) and OnPress to respond to both mouse clicks and keyboard Enter/Space activation:
var StarButton = kitex.FC("StarButton", func(_ kitex.NoProps) kitex.Node { starred, setStarred := kitex.UseState(false)
count := 128 btnStyle := buttonStyle if starred() { count = 129 btnStyle = starredButtonStyle }
return kitex.Button(kitex.ButtonProps{ Style: btnStyle, OnPress: func() { setStarred(!starred()) }, }, kitex.Textf("★ %d", count))})Styling in terminal cells
Section titled “Styling in terminal cells”Every dimension in Kite is measured in terminal cells (or percentages and fr grid tracks). Build sparse styles fluently with style.S(), chaining one property per line for clarity:
cardStyle := style.S(). Width(style.Percent(100)). Padding(1, 2). Border(style.SingleBorder().Color(style.Hex("#334866"))). Background(style.Hex("#111a2e")). Hover(style.S(). Border(style.SingleBorder().Color(style.Hex("#38bdf8"))), )Because Kite resolves :hover, :focus, :active, and :disabled inside the style engine, hover highlights do not require re-rendering your component.
Rendering lists and conditional UI
Section titled “Rendering lists and conditional UI”Use standard Go if statements for conditional rendering and kitex.Map (with a stable Key prop) when mapping slices into nodes so the reconciler preserves element focus and component state as items reorder or filter:
rows := kitex.Map(tasks, func(item Task) kitex.Node { return kitex.Box(kitex.BoxProps{ Key: item.ID, Style: rowStyle, }, kitex.Text(item.Title))})Scaling beyond one component
Section titled “Scaling beyond one component”As your TUI grows, Kite’s optional extras/* packages plug into the exact same engine without changing your component model:
Next steps
Section titled “Next steps”- Ready to build a complete app step by step? Continue to Tutorial: Task Manager.
- Want to see how a frame flows through Kite’s engine? Read Thinking in Kite.
- Need local setup instructions? Check Installation & Setup.