Home

Awesome

<!-- PROJECT LOGO --> <br /> <p align="center"> <a href="https://github.com/basarozcan/vue-tailwindcss-typeahead"> <img src="https://github.com/basarozcan/vue-tailwindcss-typeahead/raw/master/images/logo.png" alt="Logo"> </a> <h3 align="center">vue-tailwindcss-typeahead</h3> <p align="center"> Just another vue&tailwind component that present you complete typeahead/autocomplete input. <br /> <a href="https://github.com/basarozcan/vue-tailwindcss-typeahead"><strong>Explore the docs »</strong></a> <br /> <br /> <a href="https://codesandbox.io/s/vue-tailwindcss-typeahead-8qetk">View Demo on Codesandbox</a> · <a href="https://github.com/basarozcan/vue-tailwindcss-typeahead/issues">Report Bug</a> · <a href="https://github.com/basarozcan/vue-tailwindcss-typeahead/issues">Request Feature</a> </p> </p> <!-- TABLE OF CONTENTS -->

Table of Contents

<!-- ABOUT THE PROJECT -->

About The Project

<p align="center"> <img src="https://github.com/basarozcan/vue-tailwindcss-typeahead/raw/master/images/component.png" alt="component" > </p> I can't find any independent typeahead/autocomplete input component. All of them comes with UI libraries.

Built With

<!-- GETTING STARTED -->

Getting Started

To get a local copy up and running follow these simple steps.

Installation

  1. Get package from npm
npm install vue-tailwindcss-typeahead

Default Import

Import component globally:

import { VueTwTypeahead } from '@/vue-tailwindcss-typeahead.vue';
import { createApp } from "vue";

import App from "./components/App.vue";
const app = createApp(App)
app.use(VueTwTypeahead)
app.mount('#app');
<!-- USAGE EXAMPLES -->

Usage

Call the component on parent

<VueTwTypeahead 
  :lists="list"
  @selected="selectedData"
  :ignoredList="selectedItemIds"
  :clearInputWhenClicked="false"
  :inputClass="['w-full','px-3','py-2','border','border-gray-400','rounded-lg','outline-none','focus:shadow-outline']"
  placeholder="Please write a city name"
>
</VueTwTypeahead>

Code on parent component

<script>
  import {VueTwTypeahead} from '@/vue-tailwindcss-typeahead.vue';

  export default {
    name: 'ParentComponent',
    components: {
      VueTwTypeahead
    },
    data() {
      return {
        list: [
          {
            id: 1,
            name: "Amsterdam",
          },
          {
            id: 2,
            name: "Berlin",
          },
          {
            id: 3,
            name: "Istanbul",
          },
        ],
        selectedItemIds: [],
        selectedItem: null
      };
    },
    methods: {
      selectedData(value) {
        this.selectedItem = value
      },
    },
  }
</script>

Properties

propsdescriptionType
listspass an array of data. id and name attribute must be passedArray
ignoredListselected item's id will be passed to this variable and this item will not be showed if user want to change itArray
clearInputWhenClickedIf this is set to true, input will be cleared after selection. Best for multiple selectionsBoolean
inputClassTailwindcss classes can be passed to change input's classArray
placeholderplaceholder text for inputString
@selectedpoint method on parent component for custom operations
<!-- ROADMAP -->

Roadmap

See the open issues for a list of proposed features (and known issues).

<!-- CONTRIBUTING -->

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request
<!-- LICENSE -->

License

Distributed under the MIT License. See LICENSE for more information.

<!-- CONTACT -->

Contact

Twitter - @basarozcan