Skip to content

Instantly share code, notes, and snippets.

@sh-ravan
Created February 13, 2023 16:29
Show Gist options
  • Save sh-ravan/24032b7b8bd7fdb6d0038e4e0cec4246 to your computer and use it in GitHub Desktop.
Save sh-ravan/24032b7b8bd7fdb6d0038e4e0cec4246 to your computer and use it in GitHub Desktop.
<script setup>
import { ref } from 'vue';
const props = defineProps({
type: {
type: String,
default: 'text',
validator(value) {
return ['text', 'email'].includes(value);
},
},
placeholder: {
type: String,
default: 'Enter text',
},
});
const uuid = ref(`${crypto.randomUUID()}`);
</script>
<template>
<div>
<label :for="uuid" class="block text-sm font-medium text-gray-700">
<slot />
</label>
<div class="mt-1">
<input
:id="uuid"
:type="type"
:name="`input-${uuid}`"
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm"
:placeholder="placeholder"
>
</div>
</div>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment