Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-search-input

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-search-input

A Vue.js 3 search input component, inspired by the global search input of Storybook and GitHub.

  • 1.1.16
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

vue-search-input

A Vue.js 3 search input component, inspired by the global search input of Storybook and GitHub.

The SearchInput component displays a search input with some additional features built-in.

Features:

  • Focus on the search input at any time by pressing the / key on the keyboard.
  • Includes a default CSS styling but it's also easy to bring your own styles too.
  • Completely customizable icons via slots
  • Displays an x icon on the right side of the search input, used for clearing the text when there's a value typed inside.
  • The search text gets cleared by pressing the esc key when the search input has focus (configurable).

Important: It is advisable that you include the SearchInput component only once on each page.
In case multiple SearchInput components are present, the first one being displayed will take focus precedence upon the / keypress.

Demo with examples

https://vue-search-input.vercel.app

Installation

npm i vue-search-input

Usage

<template>
  <SearchInput v-model="searchVal" />
</template>

<script>
import { ref } from 'vue'
import SearchInput from 'vue-search-input'
// Optionally import default styling
import 'vue-search-input/dist/styles.css'

const searchVal = ref('')

export default {
  components: {
    SearchInput
  },
  setup() {
    return {
      searchVal
    }
  }
}
</script>

Styling

vue-search-input includes default styling (dist/styles.css) with that you can use as a base to create your own CSS. All the component's elements are inside a div which acts a wrapper for the icons and the input. The default class for the wrapper div is search-input-wrapper you can override it by providing class(es) to the SearchInput component.

Class and styles bound to the SearchInput component will be added to the wrapper div.

Events

Events bound to the SearchInput component will be passed to the input element.

NameDescriptionReturned value
update:modelValueThe updated bound modelstring

Props

NameTypeDescriptionDefault
typestringThe type of the input field. Allowed types are search and textsearch
modelValue (v-model)stringThe input's value''
wrapperClassstringThe default CSS class of the wrapper divsearch-input-wrapper
searchIconbooleanDisplays the "search" icontrue
shortcutIconbooleanDisplays the "shortcut" icontrue
clearIconbooleanDisplays the "clear text" icontrue
hideShortcutIconOnBlurbooleanWhether to hide the shortcut icon when the input loses focustrue
clearOnEscbooleanWhether to clear the input field when the esc key is pressedtrue
blurOnEscbooleanWhether to takes the focus out of the input field when the esc key is pressedtrue
selectOnFocusbooleanSelects the input's text upon / keypresstrue
shortcutListenerEnabledbooleanEnables the functionality for the / keypresstrue
shortcutKeystringThe key for the shortcut functionality/

Slots

vue-search-input includes some default icons but you can also customize them to suit your needs using the available slots.

NameDescriptionDefault content
search-iconSlot for the search icon<i class="search-icon search"></i>
shortcut-iconSlot for the shortcut icon<i class="search-icon shortcut" title='Press "/" to search'></i>
clear-iconSlot for the clear icon
{ clear: () => void } the function that clears the input
<button class="search-icon clear" aria-label="Clear" @mousedown="clear" @keydown.space.enter="clear"></button>
appendAdds an item inside the input wrapper, before the search icon-
append-innerAdds an item inside the input wrapper, after the search icon-
prependAdds an item inside the input wrapper directly after the input element-
prepend-outerAdds an item inside the input wrapper directly after the clear icon-

Keywords

FAQs

Package last updated on 21 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc