Layout Feedback
Components query their own dimensions via useContentRect(). No width prop drilling. Ink's oldest open issue (2016), solved.
Layout feedback, every terminal protocol, React + Elm architectures, 200x+ faster incremental renders. Zero native dependencies.
overflow="scroll" with scrollTo just works. No manual virtualization. Ink's #1 feature request since 2019.bun add inkx react @beorn/flexximport { Box, Text, useContentRect } from "inkx"
import { run, useInput } from "inkx/runtime"
function App() {
const { width } = useContentRect() // Components know their size!
const [count, setCount] = useState(0)
useInput((input, key) => {
if (input === "j" || key.downArrow) setCount((c) => c + 1)
if (input === "k" || key.upArrow) setCount((c) => c - 1)
if (input === "q") return "exit"
})
return (
<Box flexDirection="column">
<Text>Terminal width: {width}</Text>
<Text>Count: {count}</Text>
</Box>
)
}
await run(<App />)