-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11e0590
commit ffd16ff
Showing
5 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@qwik-ui/headless': patch | ||
--- | ||
|
||
feat: Adding the bind:open signal prop to the select component can now reactively control the select listbox open state |
34 changes: 34 additions & 0 deletions
34
apps/website/src/routes/docs/headless/select/examples/bind-open.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { component$, useSignal, useStyles$ } from '@builder.io/qwik'; | ||
import { | ||
Select, | ||
SelectListbox, | ||
SelectOption, | ||
SelectPopover, | ||
SelectTrigger, | ||
SelectValue, | ||
} from '@qwik-ui/headless'; | ||
import styles from '../snippets/select.css?inline'; | ||
|
||
export default component$(() => { | ||
useStyles$(styles); | ||
const users = ['Tim', 'Ryan', 'Jim', 'Jessie', 'Abby']; | ||
const isOpen = useSignal(false); | ||
|
||
return ( | ||
<> | ||
<button onClick$={() => (isOpen.value = true)}>Toggle open state</button> | ||
<Select bind:open={isOpen} class="select" aria-label="hero"> | ||
<SelectTrigger class="select-trigger"> | ||
<SelectValue placeholder="Select an option" /> | ||
</SelectTrigger> | ||
<SelectPopover class="select-popover"> | ||
<SelectListbox class="select-listbox"> | ||
{users.map((user) => ( | ||
<SelectOption key={user}>{user}</SelectOption> | ||
))} | ||
</SelectListbox> | ||
</SelectPopover> | ||
</Select> | ||
</> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters