[GH-ISSUE #577] feat: Add focusable option to Box #157

Closed
opened 2026-03-02 23:44:58 +03:00 by kerem · 3 comments
Owner

Originally created by @eitanalka on GitHub (Jan 23, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/577

Summary

Add a focusable option to Box so it can be made focusable (default false). This enables the existing focusedBorderColor feature to actually work.

Motivation

Currently, Box has a focusedBorderColor option but Box cannot be focused, making this option useless. Adding focusable allows users to opt-in to focus behavior.

Proposed Changes

  1. Add focusable setter to Renderable for dynamic prop updates
  2. Add focusable option to BoxOptions (default false)
  3. Add focused prop to BoxProps (React/Solid) for controlled focus state

Usage

// Imperative
const box = new Box({ focusable: true, focusedBorderColor: "blue", border: true })

// React/Solid JSX
<Box focusable focusedBorderColor="blue" border />
<Box focusable focused={isFocused} focusedBorderColor="blue" border />

Behavior

Usage Result
new Box({}) Not focusable (default)
new Box({ focusable: true }) Focusable
new Box({ focusable: true, focusedBorderColor: "blue" }) Shows blue border when focused
<Box focusable /> Focusable via JSX boolean shorthand
<Box focusable focused={signal()} /> Controlled focus state

Implementation

I have a working implementation with tests ready:

Originally created by @eitanalka on GitHub (Jan 23, 2026). Original GitHub issue: https://github.com/anomalyco/opentui/issues/577 ## Summary Add a `focusable` option to Box so it can be made focusable (default false). This enables the existing `focusedBorderColor` feature to actually work. ## Motivation Currently, Box has a `focusedBorderColor` option but Box cannot be focused, making this option useless. Adding `focusable` allows users to opt-in to focus behavior. ## Proposed Changes 1. Add `focusable` setter to `Renderable` for dynamic prop updates 2. Add `focusable` option to `BoxOptions` (default false) 3. Add `focused` prop to `BoxProps` (React/Solid) for controlled focus state ## Usage ```typescript // Imperative const box = new Box({ focusable: true, focusedBorderColor: "blue", border: true }) // React/Solid JSX <Box focusable focusedBorderColor="blue" border /> <Box focusable focused={isFocused} focusedBorderColor="blue" border /> ``` ## Behavior | Usage | Result | |-------|--------| | `new Box({})` | Not focusable (default) | | `new Box({ focusable: true })` | Focusable | | `new Box({ focusable: true, focusedBorderColor: "blue" })` | Shows blue border when focused | | `<Box focusable />` | Focusable via JSX boolean shorthand | | `<Box focusable focused={signal()} />` | Controlled focus state | ## Implementation I have a working implementation with tests ready: - **Branch:** [feat/box-focusable](https://github.com/eitanalka/opentui/tree/feat/box-focusable) - **Diff:** [View changes](https://github.com/eitanalka/opentui/compare/main...feat/box-focusable)
kerem 2026-03-02 23:44:58 +03:00
Author
Owner

@kommander commented on GitHub (Jan 24, 2026):

yep, also makes sense 👍

<!-- gh-comment-id:3795263168 --> @kommander commented on GitHub (Jan 24, 2026): yep, also makes sense 👍
Author
Owner

@eitanalka commented on GitHub (Jan 25, 2026):

yep, also makes sense 👍

Thank you. Opened a PR for this one as well.

<!-- gh-comment-id:3795811930 --> @eitanalka commented on GitHub (Jan 25, 2026): > yep, also makes sense 👍 Thank you. Opened a PR for this one as well.
Author
Owner

@kommander commented on GitHub (Jan 26, 2026):

This should be fixed with #585

<!-- gh-comment-id:3800742067 --> @kommander commented on GitHub (Jan 26, 2026): This should be fixed with #585
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#157
No description provided.