2.0.0 • Published 1 year ago

vue-tailwindcss-typeahead v2.0.0

Weekly downloads
10
License
-
Repository
-
Last release
1 year ago

Table of Contents

About The Project

Built With

  • Vue
  • Tailwindcss

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

Install the component:

import Vue from 'vue'
import VueTailwindcssTypeahead from '@/vue-tailwindcsscss-typeahead.vue';

Vue.use(VueTailwindcssTypeahead)

Browser

<link rel="stylesheet" href="vue-tailwindcss-typeahead/dist/vue-tailwindcss-typeahead.css"/>

<script src="vue.js"></script>
<script src="vue-tailwindcss-typeahead/dist/vue-tailwindcss-typeahead.min.js"></script>

If Vue is detected, the plugin will be installed automatically. If not, install the component:

Vue.use(VueTailwindcssTypeahead)

Usage

Call the component on parent

<vue-tailwindcsscss-typeahead 
  :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">
  </vue-tailwindcsscss-typeahead>

Code on parent component

<script>
  import Vue from 'vue';
  import VueTailwindcssTypeahead from '@/vue-tailwindcsscss-typeahead.vue';

  export default Vue.extend({
    name: 'ParentComponent',
    components: {
      VueTailwindcssTypeahead
    },
    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

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

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

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

Contact

Twitter - @basarozcan

2.0.0

1 year ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.0

3 years ago