Skip to content

Instantly share code, notes, and snippets.

@plugn
Last active November 23, 2018 17:09
Show Gist options
  • Save plugn/07eb0c0ea7072f0c157fac3a715e4301 to your computer and use it in GitHub Desktop.
Save plugn/07eb0c0ea7072f0c157fac3a715e4301 to your computer and use it in GitHub Desktop.
Sexy Input for Semantic-UI
<template>
<div class="ui icon input">
<input
:placeholder="placeholder"
:value="value"
@input="onInput"
@blur="onBlur"
ref="input"
/><i
class="icon" :class="value ? 'close link' : icon"
@click="onClear"
></i>
</div>
</template>
<script>
export default {
name: 'InputPlus',
props: {
icon: {
type: String,
default: 'search'
},
value: [String, Number],
placeholder: {
type: String,
default: 'Search...'
},
},
events: {
input: {
custom: true,
},
blur: {
custom: true,
},
},
methods: {
onClear(e) {
this.$emit('input', '');
},
onInput(e) {
this.$emit('input', e.target.value);
},
onBlur(e) {
this.$emit('blur', e);
},
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment