Avatar Upload
Circular avatar image upload with preview
Preview
Profile Picture
JPG, PNG or GIF. Max 2MB.
Click the camera icon to upload
{ window.Prism.highlightElement($refs.codeEl) }) }"
class="w-full flex items-center justify-between px-6 py-4 text-left bg-gray-50 dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer">
View Code
<div x-data="{ avatar: null }">
<div class="relative w-32 h-32 rounded-full bg-gray-200 dark:bg-gray-700 overflow-hidden">
<img x-show="avatar" :src="avatar" class="w-full h-full object-cover">
<label class="absolute bottom-0 right-0 bg-blue-600 text-white p-2 rounded-full cursor-pointer">
<input type="file" class="hidden" accept="image/*" @change="
const file = $event.target.files[0];
if (file) { const reader = new FileReader(); reader.onload = (e) => avatar = e.target.result; reader.readAsDataURL(file); }
">
</label>
</div>
</div>