-
Notifications
You must be signed in to change notification settings - Fork 162
Open
Labels
coreThis relates to the core packageThis relates to the core packageenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
I have four <select> elements side-by-side:
In the screenshot, the second <select> is focused.
I would like the possibility to have no selected option when an select isn't focused.
Meaning: no triangle, no yellow text, no blue background.
An alternative could be that the selected option looks different when the <select> is not focused compared to when it is focused.
Below is my sample code. You can change the focused <select> using the left and right arrow keys.
import { render, useKeyboard } from "@opentui/react"
import type { SelectOption } from "@opentui/core"
import { useState } from "react"
function App() {
const [focused, setFocused] = useState<0 | 1 | 2 | 3>(0)
useKeyboard((key) => {
if (key.name === "left") {
if (focused === 0) {
// none
} else if (focused === 1) {
setFocused(0)
} else if (focused === 2) {
setFocused(1)
} else if (focused === 3) {
setFocused(2)
}
} else if (key.name === "right") {
if (focused === 0) {
setFocused(1)
} else if (focused === 1) {
setFocused(2)
} else if (focused === 2) {
setFocused(3)
} else if (focused === 3) {
// none
}
}
})
const options: SelectOption[] = [
{ name: "Option 1", description: "Option 1 description", value: "opt1" },
{ name: "Option 2", description: "Option 2 description", value: "opt2" },
{ name: "Option 3", description: "Option 3 description", value: "opt3" },
]
return (
<box style={{ flexDirection: 'row', width: '100%' }}>
<box style={{ border: true, height: '100%', width: '25%' }}>
<select
style={{ height: '100%', width: '100%' }}
options={options}
focused={focused === 0}
/>
</box>
<box style={{ border: true, height: '100%', width: '25%' }}>
<select
style={{ height: '100%', width: '100%' }}
options={options}
focused={focused === 1}
/>
</box>
<box style={{ border: true, height: '100%', width: '25%' }}>
<select
style={{ height: '100%', width: '100%' }}
options={options}
focused={focused === 2}
/>
</box>
<box style={{ border: true, height: '100%', width: '25%' }}>
<select
style={{ height: '100%', width: '100%' }}
options={options}
focused={focused === 3}
/>
</box>
</box>
)
}
render(<App />)
Metadata
Metadata
Assignees
Labels
coreThis relates to the core packageThis relates to the core packageenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers