Command Bar
Search input that stays visible in a top bar or toolbar. The border turns accent-colored with a glow ring on focus.
<arc-command-bar>Overview
CommandBar is a search field for a TopBar or toolbar. It renders an icon, a text input and a hint slot. It fires arc-input on every keystroke and arc-submit on Enter, both with { value }. It doesn't render results: show them in a dropdown or popover, or send the submitted value to a results page.
Use it where people search all the time, as in an admin dashboard or a docs site. When search is occasional, use CommandPalette, a modal overlay you open on demand.
Guidelines
Do
- Write a placeholder that names the scope, such as "Search docs..."
- If there's more than one on a page, give each a different `label`. Otherwise they're all announced as "Search"
- Give it a max-width so it doesn't take over the toolbar
Don't
- Don't use it as a general text input. It's styled and labeled for search
Features
- `label` sets the input's `aria-label` and defaults to "Search". The placeholder is never used as the name
- `icon` takes any Phosphor icon name and defaults to `magnifying-glass`
- Enter is claimed, so inside a `<form>` it fires `arc-submit` without also submitting the form
- Set `value` from outside to control the input
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<script type="module" src="@arclux/arc-ui"></script>
<arc-command-bar placeholder="Search..." id="search"></arc-command-bar>
<script>
const bar = document.querySelector('#search');
bar.addEventListener('arc-input', (e) => {
console.log('typing:', e.detail.value);
});
bar.addEventListener('arc-submit', (e) => {
console.log('submitted:', e.detail.value);
});
</script>import { CommandBar } from '@arclux/arc-ui-react';
export function AppSearch() {
return (
<CommandBar
placeholder="Search..."
onArcInput={(e) => console.log('typing:', e.detail.value)}
onArcSubmit={(e) => console.log('submitted:', e.detail.value)}
/>
);
}<script setup>
import { CommandBar } from '@arclux/arc-ui-vue';
function onInput(e) {
console.log('typing:', e.detail.value);
}
function onSubmit(e) {
console.log('submitted:', e.detail.value);
}
</script>
<template>
<CommandBar
placeholder="Search..."
@arc-input="onInput"
@arc-submit="onSubmit"
/>
</template><script>
import { CommandBar } from '@arclux/arc-ui-svelte';
function handleInput(e) {
console.log('typing:', e.detail.value);
}
function handleSubmit(e) {
console.log('submitted:', e.detail.value);
}
</script>
<CommandBar
placeholder="Search..."
on:arc-input={handleInput}
on:arc-submit={handleSubmit}
/>import { Component } from '@angular/core';
import { CommandBar } from '@arclux/arc-ui-angular';
@Component({
imports: [CommandBar],
template: `
<arc-command-bar
placeholder="Search..."
(arc-input)="onInput($event)"
(arc-submit)="onSubmit($event)"
/>
`,
})
export class AppSearchComponent {
onInput(e: CustomEvent) {
console.log('typing:', e.detail.value);
}
onSubmit(e: CustomEvent) {
console.log('submitted:', e.detail.value);
}
}import { CommandBar } from '@arclux/arc-ui-solid';
export function AppSearch() {
return (
<CommandBar
placeholder="Search..."
onArcInput={(e) => console.log('typing:', e.detail.value)}
onArcSubmit={(e) => console.log('submitted:', e.detail.value)}
/>
);
}import { CommandBar } from '@arclux/arc-ui-preact';
export function AppSearch() {
return (
<CommandBar
placeholder="Search..."
onArcInput={(e) => console.log('typing:', e.detail.value)}
onArcSubmit={(e) => console.log('submitted:', e.detail.value)}
/>
);
}API
placeholderstring'Search…'- Placeholder text displayed when the input is empty. Use it to communicate the scope of the search.
valuestring''- The current value of the input. Set externally to control the input state programmatically.
iconstring'magnifying-glass'- Icon name displayed before the input. Accepts any Phosphor icon name.
labelstring''- Accessible name for the input, applied as
aria-label. Defaults to "Search". A placeholder is not a name: it is announced inconsistently and disappears the moment the user types.
Events
arc-inputdetail:{ value: string }- Fired on every keystroke with detail: { value }.
arc-submitdetail:{ value: string }- Fired when the user presses Enter with detail: { value }.