Hooks
useTerminalDimensions
Get the current terminal dimensions
The useTerminalDimensions hook returns the current terminal dimensions in
columns and rows. It automatically updates when the terminal is resized.
import { useTerminalDimensions } from "@gridland/utils"Usage
function MyComponent() {
const { width, height } = useTerminalDimensions()
return (
<text>Terminal is {width}x{height}</text>
)
}function ResponsiveLayout() {
const { width } = useTerminalDimensions()
if (width < 60) {
return <NarrowLayout />
}
return <WideLayout />
}Returns
| Property | Type | Description |
|---|---|---|
width | number | Terminal width in columns |
height | number | Terminal height in rows |