Skip to content

React Bindings

The React package provides React components and hooks for BetterTUI.

<Box
flexDirection="row"
justifyContent="center"
alignItems="center"
padding={1}
gap={1}
borderStyle="round"
width={40}
height={10}
>
{children}
</Box>
<Text bold color="cyan" dimColor italic underline>
Hello, World!
</Text>
<Button onPress={handlePress} isDisabled={false}>
Click me
</Button>
<Input
value={value}
onChange={setValue}
onSubmit={handleSubmit}
placeholder="Type here"
mask="*"
/>
useInput((key, event) => {
// Handle key press
}, isActive);
const [isFocused, focusProps] = useFocus();
const { exit, isRawModeSupported, rawMode } = useApp();
const [columns, rows] = useStdoutDimensions();
const { theme, setTheme, toggleTheme } = useTheme();
const { value, start, stop } = useAnimation({
from: 0,
to: 100,
duration: 1000,
easing: 'easeInOut',
});
useEvent('custom:event', (data) => {
// Handle event
});
import { render } from '@bettertui/react';
render(<App />, {
exitOnCtrlC: true,
stdin: process.stdin,
stdout: process.stdout,
});