Skip to content

Commit b7f578a

Browse files
authored
feat: add clear button to search input (#101)
1 parent 72cd3be commit b7f578a

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

app/pages/search.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,20 @@ defineOgImageComponent('Default', {
370370
autocomplete="off"
371371
autocorrect="off"
372372
spellcheck="false"
373-
class="w-full max-w-full bg-bg-subtle border border-border rounded-lg pl-8 pr-4 py-3 font-mono text-base text-fg placeholder:text-fg-subtle transition-colors duration-300 focus:(border-border-hover outline-none) appearance-none"
373+
class="w-full max-w-full bg-bg-subtle border border-border rounded-lg pl-8 pr-10 py-3 font-mono text-base text-fg placeholder:text-fg-subtle transition-colors duration-300 focus:(border-border-hover outline-none) appearance-none"
374374
@focus="isSearchFocused = true"
375375
@blur="isSearchFocused = false"
376376
@keydown="handleResultsKeydown"
377377
/>
378+
<button
379+
v-show="inputValue"
380+
type="button"
381+
class="absolute right-3 text-fg-subtle hover:text-fg transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50 rounded"
382+
aria-label="Clear search"
383+
@click="inputValue = ''"
384+
>
385+
<span class="i-carbon-close-large block w-3.5 h-3.5" aria-hidden="true" />
386+
</button>
378387
<!-- Hidden submit button for accessibility (form must have submit button per WCAG) -->
379388
<button type="submit" class="sr-only">Search</button>
380389
</div>

0 commit comments

Comments
 (0)