<div class="demo-caption">Filter a list as you type</div>
<div class="demo-filter">
<div class="demo-filter-bar">
<ray-search id="demo-pkg-search" aria-label="Search packages" placeholder="Search packages…" shortcut="/" debounce="0"></ray-search>
<span class="demo-muted" id="demo-pkg-count">8 packages</span>
</div>
<ul class="demo-pkg-list" id="demo-pkg-list">
<li data-keywords="http server router middleware"><strong>web</strong><span>The Express-style framework: routes, middleware, sessions.</span></li>
<li data-keywords="http server client tls websocket"><strong>net</strong><span>Production HTTP server and client, TLS, WebSocket.</span></li>
<li data-keywords="api calls typed"><strong>rpc</strong><span>Typed calls between a backend and its clients.</span></li>
<li data-keywords="sql postgres sqlite migrations"><strong>db</strong><span>SQL with migrations: SQLite and Postgres.</span></li>
<li data-keywords="components web design ui"><strong>ray-elements</strong><span>This design system: web components with raylang extras.</span></li>
<li data-keywords="test browser webview"><strong>webtest</strong><span>Browser tests that run in the real webview.</span></li>
<li data-keywords="queue jobs background cron"><strong>jobs</strong><span>Background jobs and schedules.</span></li>
<li data-keywords="log metrics tracing"><strong>observe</strong><span>Logs, metrics and traces.</span></li>
</ul>
<p class="demo-pkg-empty" id="demo-pkg-empty" hidden>No package matches <b id="demo-pkg-query"></b>.</p>
</div>
<div class="demo-caption">ray-search: once the typing pauses</div>
<div class="demo-split">
<div class="demo-stack">
<ray-search id="demo-search" label="Search the docs" placeholder="Try “dialog” or “tokens”"></ray-search>
<span class="demo-muted">ray-search fires 200 ms after the last key (debounce); input fires on every key.</span>
</div>
<ol class="demo-log" id="demo-search-log"><li class="demo-muted">Queries appear here.</li></ol>
</div>
<div class="demo-caption">Variants, sizes and radius</div>
<div class="demo-grid">
<ray-search label="Filled (the default)" placeholder="Name or file"></ray-search>
<ray-search label="Bordered" variant="default" placeholder="Name or file"></ray-search>
<ray-search label="Large, round" size="lg" radius="full" placeholder="Search everything"></ray-search>
<ray-search label="Extra small" size="xs" placeholder="Filter"></ray-search>
<ray-search label="With a value" value="ray-dialog"></ray-search>
<ray-search label="Disabled" placeholder="Offline" disabled></ray-search>
</div>
<div class="demo-unstyled">
<ray-search aria-label="Search in the toolbar" variant="unstyled" placeholder="Unstyled: for a toolbar or a header"></ray-search>
</div>
<script type="module">
const search = document.getElementById("demo-pkg-search");
const items = [...document.querySelectorAll("#demo-pkg-list li")];
search.addEventListener("input", () => {
const q = (search.value ?? "").trim().toLowerCase();
let shown = 0;
for (const li of items) {
const hit = !q || li.textContent.toLowerCase().includes(q) || li.dataset.keywords.includes(q);
li.hidden = !hit;
shown += hit;
}
document.getElementById("demo-pkg-count").textContent = `${shown} package${shown === 1 ? "" : "s"}`;
document.getElementById("demo-pkg-empty").hidden = shown > 0;
document.getElementById("demo-pkg-query").textContent = `“${q}”`;
});
const log = document.getElementById("demo-search-log");
document.getElementById("demo-search").addEventListener("ray-search", (e) => {
log.querySelector(".demo-muted")?.remove();
const li = document.createElement("li");
li.textContent = e.detail.value ? `“${e.detail.value}”` : "cleared";
log.prepend(li);
while (log.children.length > 5) log.lastElementChild.remove();
});
</script>
import { RaySearch } from "@raylang/react";
export function SearchExample() {
return (
<>
<div className="demo-caption">Filter a list as you type</div>
<div className="demo-filter">
<div className="demo-filter-bar">
<RaySearch id="demo-pkg-search" aria-label="Search packages" placeholder="Search packages…" shortcut="/" debounce={0} />
<span className="demo-muted" id="demo-pkg-count">8 packages</span>
</div>
<ul className="demo-pkg-list" id="demo-pkg-list">
<li data-keywords="http server router middleware"><strong>web</strong><span>The Express-style framework: routes, middleware, sessions.</span></li>
<li data-keywords="http server client tls websocket"><strong>net</strong><span>Production HTTP server and client, TLS, WebSocket.</span></li>
<li data-keywords="api calls typed"><strong>rpc</strong><span>Typed calls between a backend and its clients.</span></li>
<li data-keywords="sql postgres sqlite migrations"><strong>db</strong><span>SQL with migrations: SQLite and Postgres.</span></li>
<li data-keywords="components web design ui"><strong>ray-elements</strong><span>This design system: web components with raylang extras.</span></li>
<li data-keywords="test browser webview"><strong>webtest</strong><span>Browser tests that run in the real webview.</span></li>
<li data-keywords="queue jobs background cron"><strong>jobs</strong><span>Background jobs and schedules.</span></li>
<li data-keywords="log metrics tracing"><strong>observe</strong><span>Logs, metrics and traces.</span></li>
</ul>
<p className="demo-pkg-empty" id="demo-pkg-empty" hidden>No package matches <b id="demo-pkg-query" />.</p>
</div>
<div className="demo-caption">ray-search: once the typing pauses</div>
<div className="demo-split">
<div className="demo-stack">
<RaySearch id="demo-search" label="Search the docs" placeholder="Try “dialog” or “tokens”" />
<span className="demo-muted">ray-search fires 200 ms after the last key (debounce); input fires on every key.</span>
</div>
<ol className="demo-log" id="demo-search-log"><li className="demo-muted">Queries appear here.</li></ol>
</div>
<div className="demo-caption">Variants, sizes and radius</div>
<div className="demo-grid">
<RaySearch label="Filled (the default)" placeholder="Name or file" />
<RaySearch label="Bordered" variant="default" placeholder="Name or file" />
<RaySearch label="Large, round" size="lg" radius="full" placeholder="Search everything" />
<RaySearch label="Extra small" size="xs" placeholder="Filter" />
<RaySearch label="With a value" value="ray-dialog" />
<RaySearch label="Disabled" placeholder="Offline" disabled />
</div>
<div className="demo-unstyled">
<RaySearch aria-label="Search in the toolbar" variant="unstyled" placeholder="Unstyled: for a toolbar or a header" />
</div>
</>
);
}
<template>
<div class="demo-caption">Filter a list as you type</div>
<div class="demo-filter">
<div class="demo-filter-bar">
<RaySearch id="demo-pkg-search" aria-label="Search packages" placeholder="Search packages…" shortcut="/" :debounce="0" />
<span class="demo-muted" id="demo-pkg-count">8 packages</span>
</div>
<ul class="demo-pkg-list" id="demo-pkg-list">
<li data-keywords="http server router middleware"><strong>web</strong><span>The Express-style framework: routes, middleware, sessions.</span></li>
<li data-keywords="http server client tls websocket"><strong>net</strong><span>Production HTTP server and client, TLS, WebSocket.</span></li>
<li data-keywords="api calls typed"><strong>rpc</strong><span>Typed calls between a backend and its clients.</span></li>
<li data-keywords="sql postgres sqlite migrations"><strong>db</strong><span>SQL with migrations: SQLite and Postgres.</span></li>
<li data-keywords="components web design ui"><strong>ray-elements</strong><span>This design system: web components with raylang extras.</span></li>
<li data-keywords="test browser webview"><strong>webtest</strong><span>Browser tests that run in the real webview.</span></li>
<li data-keywords="queue jobs background cron"><strong>jobs</strong><span>Background jobs and schedules.</span></li>
<li data-keywords="log metrics tracing"><strong>observe</strong><span>Logs, metrics and traces.</span></li>
</ul>
<p class="demo-pkg-empty" id="demo-pkg-empty" hidden>No package matches <b id="demo-pkg-query"></b>.</p>
</div>
<div class="demo-caption">ray-search: once the typing pauses</div>
<div class="demo-split">
<div class="demo-stack">
<RaySearch id="demo-search" label="Search the docs" placeholder="Try “dialog” or “tokens”" />
<span class="demo-muted">ray-search fires 200 ms after the last key (debounce); input fires on every key.</span>
</div>
<ol class="demo-log" id="demo-search-log"><li class="demo-muted">Queries appear here.</li></ol>
</div>
<div class="demo-caption">Variants, sizes and radius</div>
<div class="demo-grid">
<RaySearch label="Filled (the default)" placeholder="Name or file" />
<RaySearch label="Bordered" variant="default" placeholder="Name or file" />
<RaySearch label="Large, round" size="lg" radius="full" placeholder="Search everything" />
<RaySearch label="Extra small" size="xs" placeholder="Filter" />
<RaySearch label="With a value" value="ray-dialog" />
<RaySearch label="Disabled" placeholder="Offline" disabled />
</div>
<div class="demo-unstyled">
<RaySearch aria-label="Search in the toolbar" variant="unstyled" placeholder="Unstyled: for a toolbar or a header" />
</div>
</template>