Created
February 13, 2023 16:29
-
-
Save sh-ravan/24032b7b8bd7fdb6d0038e4e0cec4246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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