A Web Component that provides typeahead suggestions for AT Protocol (Bluesky) handles. Uses the public app.bsky.actor.searchActorsTypeahead API directly from the client.
···1+MIT License
2+3+Copyright (c) 2025 Tijs Teulings
4+5+Permission is hereby granted, free of charge, to any person obtaining a copy
6+of this software and associated documentation files (the "Software"), to deal
7+in the Software without restriction, including without limitation the rights
8+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+copies of the Software, and to permit persons to whom the Software is
10+furnished to do so, subject to the following conditions:
11+12+The above copyright notice and this permission notice shall be included in all
13+copies or substantial portions of the Software.
14+15+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+SOFTWARE.
···1+# actor-typeahead
2+3+A Web Component that provides typeahead suggestions for AT Protocol (Bluesky)
4+handles. Uses the public `app.bsky.actor.searchActorsTypeahead` API directly
5+from the client.
6+7+## Usage
8+9+```html
10+<script type="module" src="https://esm.sh/jsr/@tijs/actor-typeahead"></script>
11+12+<actor-typeahead>
13+ <input type="text" placeholder="alice.bsky.social" />
14+</actor-typeahead>
15+```
16+17+Or import in JavaScript/TypeScript:
18+19+```ts
20+import "@tijs/actor-typeahead";
21+```
22+23+## Attributes
24+25+| Attribute | Default | Description |
26+| --------- | ----------------------------- | ------------------------- |
27+| `host` | `https://public.api.bsky.app` | API host for actor search |
28+| `rows` | `5` | Max suggestions to show |
29+30+## CSS Custom Properties
31+32+Style the dropdown via custom properties on `<actor-typeahead>`:
33+34+| Property | Default |
35+| ------------------------- | --------- |
36+| `--color-background` | `#ffffff` |
37+| `--color-border` | `#e5e7eb` |
38+| `--color-shadow` | `#000000` |
39+| `--color-hover` | `#fff1f1` |
40+| `--color-avatar-fallback` | `#fecaca` |
41+| `--radius` | `8px` |
42+| `--padding-menu` | `4px` |
43+44+## How it works
45+46+Wrap any `<input>` element. The component listens for `input` events on the
47+slotted input, fetches matching actors, and displays them in a dropdown. When a
48+suggestion is selected (via click or keyboard), the input value is set and a
49+native `input` event is dispatched so frameworks (React, etc.) can detect the
50+change.
51+52+Keyboard navigation: Arrow keys, Page Up/Down, Enter to select, Escape to
53+dismiss.
54+55+## Disabling auto-registration
56+57+Pass `?tag=none` in the import URL to prevent auto-registration:
58+59+```ts
60+import { ActorTypeahead } from "@tijs/actor-typeahead?tag=none";
61+customElements.define("my-typeahead", ActorTypeahead);
62+```
63+64+## License
65+66+MIT