Skip to content

Component ​

Wrap content in the component, then change the v-model value to enter or exit fullscreen. Exiting fullscreen automatically sets the bound value to false.

Playground ​

Edit this example

Loading example…

vue
<script setup>
import { ref } from 'vue'
import { Fullscreen } from 'vue-fullscreen'

const isFullscreen = ref(false)

function report(error) {
  isFullscreen.value = false
  console.error(error)
}
</script>

<template>
  <div>
    <button :disabled="isFullscreen" @click="isFullscreen = true">
      Enter fullscreen
    </button>
    <Fullscreen
      v-model="isFullscreen"
      :page-only="false"
      :teleport="true"
      @error="report"
    >
      <button v-if="isFullscreen" @click="isFullscreen = false">
        Exit fullscreen
      </button>
      <!-- Your fullscreen content -->
    </Fullscreen>
  </div>
</template>

Component props ​

PropTypeDefaultPurpose
modelValuebooleanfalsev-model value
pageOnlybooleanfalseFill the page; automatic fallback if native fullscreen is unavailable
teleportbooleanfalseMove the element to the body while active
fullscreenClassstring'fullscreen'Class applied while active
exitOnClickWrapperbooleantrueExit on wrapper background clicks, not child clicks

Instance properties ​

Read these through the component ref.

PropertyTypePurpose
isFullscreenbooleanCurrent fullscreen state
isSupportedbooleanNative API support

Events ​

EventArgumentPurpose
changebooleanFullscreen state changed
update:modelValuebooleanSynchronize v-model
errorError objectA model change or wrapper click triggered a failed operation

Methods ​

vue
<script setup>
import { ref } from 'vue'
import { Fullscreen } from 'vue-fullscreen'

const panel = ref()
const error = ref('')
async function enter() {
  try {
    await panel.value.enter()
  } catch (reason) {
    error.value = reason.message
  }
}
</script>

<template>
  <button @click="enter">Enter fullscreen</button>
  <Fullscreen ref="panel" page-only>Content</Fullscreen>
  <p v-if="error" role="alert">{{ error }}</p>
</template>
MethodSignaturePurpose
enter(): Promise<void>Enter fullscreen
exit(): Promise<void>Exit fullscreen
toggle(force?: boolean): Promise<void>Toggle or force a state

Migrating older versions ​

Use enter() instead of request(), and isSupported instead of isEnabled. The old names remain compatibility aliases.

The legacy fullscreen prop and update:fullscreen event remain available for compatibility. Use v-model in new code.

js
// Before
import VueFullscreen from 'vue-fullscreen'
app.use(VueFullscreen)

// Now
import { Fullscreen } from 'vue-fullscreen'
vue
<!-- Before -->
<fullscreen
  :fullscreen="isFullscreen"
  @update:fullscreen="isFullscreen = $event"
/>

<!-- Now -->
<Fullscreen v-model="isFullscreen" />

Released under the MIT License.