AI Input Search
エーアイインプットサーチ
A composer that grows with what is typed into it and carries a web-search toggle in its toolbar. The textarea is collapsed to its floor before every measurement, because scrollHeight↗↗ only reports a smaller number once the element has stopped holding itself open — measure without collapsing first and the field can only ever get taller. The search pill animates its width rather than swapping its label in and out, so the toolbar never jumps as it opens. Enter submits, Shift+Enter breaks the line. Adapted from Kokonut UI↗↗ under the MIT licence.
Installation
Copy and paste the following code into a new component file:1
How to use it2
Props
AiInputSearch
| Name | Default | Description |
|---|---|---|
| placeholder | "Search the web..." | string Placeholder shown in the empty field |
| searchLabel | "Search" | string Label revealed when the search pill is on |
| minHeight | 52 | number Height in pixels the field collapses back to |
| maxHeight | 200 | number Height in pixels past which the field scrolls instead of growing |
| onSubmit | — | (value: string, search: boolean) => void Called on Enter or the send button, with the state of the search pill |
| dark | false | boolean Render the dark palette |