Skip to content

Modal ​

Formalar, tafsilotlar va murakkab kontent uchun umumiy maqsadli overlay panel. Sudrash, fullscreen, drawer rejimi, maxsus animatsiyalar, ustma-ust modallar, focus trap, avtomatik yopilish, dasturiy API va boshqa koʻplab imkoniyatlarni qoʻllab-quvvatlaydi.

vue
<script setup>
const show = ref(false)
</script>

<template>
  <button @click="show = true">Open Modal</button>
  <VxModal v-model="show" title="Basic Modal">
    <p>This is a basic modal.</p>
  </VxModal>
</template>

With Description ​

vue
<template>
  <VxModal v-model="show" title="Edit Profile" description="Make changes here." />
</template>

Sizes ​

vue
<template>
  <VxModal size="sm" />
  <VxModal size="md" />
  <VxModal size="lg" />
  <VxModal size="xl" />
  <VxModal size="full" />
</template>

Custom Width ​

width prop orqali istalgan kenglikni belgilang.

vue
<template>
  <VxModal v-model="show" :width="666" title="Custom Width" />
  <VxModal v-model="show" width="80%" title="Percentage Width" />
</template>

Draggable ​

Modalni joyidan koʻchirish uchun uning sarlavhasidan ushlab sudrang.

vue
<template>
  <VxModal v-model="show" title="Drag Me" draggable />
</template>

Fullscreen Toggle ​

Sarlavhadagi tugma foydalanuvchilarga modalni fullscreen rejimga va orqaga qaytarishga imkon beradi.

vue
<template>
  <VxModal v-model="show" title="Expand Me" fullscreenable />
</template>

Before Close ​

Yopilishdan oldin ishga tushadigan asinxron himoya. Yopilishni toʻxtatish uchun false qaytaring.

vue
<script setup>
// Sync — native browser confirm
function beforeClose() {
  return window.confirm('Discard changes?')
}

// Async — with useConfirm dialog
import { useConfirm } from 'veloxui'
const dialog = useConfirm()

async function beforeCloseAsync() {
  // resolves = allow close, rejects = block close
  await dialog.warning({
    title: 'Discard Changes?',
    confirmText: 'Discard',
    cancelText: 'Keep Editing',
  })
}
</script>

<template>
  <VxModal v-model="show" :before-close="beforeClose" title="Guard" />
</template>

Drawer Mode ​

Istalgan chetdan sirgʻalib chiqadi. drawer propda left, right, top yoki bottom qiymatlaridan foydalaning.

vue
<template>
  <VxModal v-model="show" drawer="left" title="Left" />
  <VxModal v-model="show" drawer="right" title="Right" />
  <VxModal v-model="show" drawer="top" title="Top" />
  <VxModal v-model="show" drawer="bottom" title="Bottom" />
  <VxModal v-model="show" drawer="right" size="lg" title="Wide Drawer" />
</template>

Custom Transitions ​

Animatsiyani tanlang: zoom (standart), fade, slide-up, slide-down, flip.

vue
<template>
  <VxModal transition="fade" />
  <VxModal transition="slide-up" />
  <VxModal transition="slide-down" />
  <VxModal transition="flip" />
</template>

Stacked Modals ​

Boshqa modallar ustiga modal oching. Har biriga avtomatik ravishda yuqoriroq z-index beriladi.

vue
<template>
  <VxModal v-model="first" title="First">
    <template #footer>
      <button @click="second = true">Open Second</button>
    </template>
  </VxModal>
  <VxModal v-model="second" title="Second" />
</template>

Focus Trap ​

Standart holatda yoqilgan. Tab tugmasi foydalanish qulayligi uchun modal ichida aylanadi.

vue
<template>
  <!-- Focus trap is enabled by default -->
  <VxModal v-model="show" title="Focus Trap">
    <input placeholder="Tab cycles here" />
  </VxModal>

  <!-- Disable it -->
  <VxModal v-model="show" :focus-trap="false" />
</template>

Auto Close ​

Belgilangan vaqtdan (ms) keyin avtomatik yopiladi.

vue
<template>
  <VxModal v-model="show" :auto-close="3000" title="Closes in 3s" />
</template>

Destroy on Close ​

Standart holatda, modal yopilganda kontent yoʻq qilinadi (destroy-on-close). Kontentni saqlab qolish uchun (forma holati, scroll joylashuvi va h.k. saqlanadi) uni false qilib belgilang.

vue
<template>
  <VxModal v-model="show" :destroy-on-close="false" title="Keep Alive" />
</template>

Persistent ​

Overlay bosish yoki Escape tugmasi orqali yopib boʻlmaydi. Silkinish animatsiyasini koʻrsatadi.

vue
<template>
  <VxModal v-model="show" persistent title="Persistent" />
</template>

Position ​

Modalni viewportning istalgan burchagi yoki chetiga joylashtiring.

vue
<template>
  <VxModal v-model="show" position="top-left" title="Top Left" />
  <VxModal v-model="show" position="top-center" title="Top Center" />
  <VxModal v-model="show" position="top-right" title="Top Right" />
  <VxModal v-model="show" position="center" title="Center (default)" />
  <VxModal v-model="show" position="bottom-left" title="Bottom Left" />
  <VxModal v-model="show" position="bottom-center" title="Bottom Center" />
  <VxModal v-model="show" position="bottom-right" title="Bottom Right" />
</template>

Centered vs Top ​

vue
<template>
  <VxModal v-model="show" :centered="false" title="Top" />
</template>

Hide Overlay ​

vue
<template>
  <VxModal v-model="show" hide-overlay />
</template>

Loading ​

vue
<template>
  <VxModal v-model="show" loading title="Processing..." />
</template>

Scrollable Content ​

vue
<template>
  <VxModal v-model="show" title="Terms" size="sm">
    <div v-for="i in 20" :key="i"><p>Long content...</p></div>
  </VxModal>
</template>
vue
<template>
  <VxModal v-model="show">
    <template #header>Custom header</template>
    <template #footer>
      <button @click="show = false">Cancel</button>
      <button @click="show = false">Confirm</button>
    </template>
  </VxModal>
</template>

Programmatic API ​

Template markup yozmasdan JavaScript orqali modallarni ochish uchun useModal() composable’idan foydalaning.

vue
<script setup>
import { useModal } from 'veloxui'

const { open } = useModal()

function showModal() {
  const instance = open({
    title: 'Hello',
    content: 'Created from JavaScript!',
    size: 'sm',
  })

  // Close programmatically
  // instance.close()
}

function showDrawer() {
  open({
    title: 'Drawer',
    drawer: 'right',
    content: 'A programmatic drawer.',
    autoClose: 3000,
  })
}
</script>

Teleport Target ​

Modalni body oʻrniga maxsus konteynerga joylashtiring.

vue
<template>
  <VxModal v-model="show" teleport-to="#my-container" />
</template>

Props ​

PropTypeDefaultDescription
modelValuebooleanfalseKoʻrsatish/yashirish (v-model)
titlestring''Sarlavha matni
descriptionstring''Sarlavha ostidagi qoʻshimcha matn
size'sm' | 'md' | 'lg' | 'xl' | 'full''md'Modal kengligi
widthstring | number—Maxsus kenglik (size’ni almashtiradi)
closablebooleantrueYopish tugmasini koʻrsatish
closeOnOverlaybooleantrueOverlay bosilganda yopilish
closeOnEscbooleantrueEscape bosilganda yopilish
centeredbooleantrueVertikal markazlash
persistentbooleanfalseYopish oʻrniga silkinish
hideOverlaybooleanfalseShaffof fon
loadingbooleanfalseYuklash overlay’ini koʻrsatish
draggablebooleanfalseSarlavhadan sudrash
fullscreenablebooleanfalseFullscreen tugmasini koʻrsatish
beforeClose() => boolean | Promise<boolean>—Yopilishdan oldingi himoya
drawer'left' | 'right' | 'top' | 'bottom'—Drawer rejimi
transition'zoom' | 'fade' | 'slide-up' | 'slide-down' | 'flip'—Animatsiya
focusTrapbooleantrueTab modal ichida qoladi
autoClosenumber0ms’dan keyin avtomatik yopilish
destroyOnClosebooleantrueYopilganda kontentni yoʻq qilish
teleportTostring'body'Teleport selektor nishoni
position'center' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right''center'Modal joylashuvi

Events ​

EventDescription
update:modelValueQiymat oʻzgardi
closeYopish ishga tushirildi
openedKirish animatsiyasi tugadi
closedChiqish animatsiyasi tugadi

Slots ​

SlotDescription
defaultAsosiy kontent
headerMaxsus sarlavha
footerFooter amallari (standart: Yopish tugmasi)

Exposed Methods ​

MethodDescription
close()Modalni dasturiy tarzda yopish
toggleFullscreen()Fullscreen holatini almashtirish