Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-modal-video

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-modal-video

Modal Video Viewer

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

next-modal-video

React Modal Video Component

Features

  • Not affected by dom structure.
  • Beautiful transition
  • Accessible for keyboard navigation and screen readers.
  • Rich options for youtube API and Vimeo API

Install

npm

npm install next-modal-video

Usage

import sass file to your project

@import 'node_modules/next-modal-video/scss/modal-video.scss';

Functional Implementation with Hooks

import React,{useState} from 'react'
import ReactDOM from 'react-dom'
import ModalVideo from 'next-modal-video'

const App = () => {

	const [isOpen, setOpen] = useState(false)

	return (
		<React.Fragment>
			<ModalVideo channel='youtube' autoplay isOpen={isOpen} videoId="L61p2uyiMSo" onClose={() => setOpen(false)} />

			<button className="btn-primary" onClick={()=> setOpen(true)}>VIEW DEMO</button>
		</React.Fragment>
	)
}

ReactDOM.render(
  <App />,
    document.getElementById('root')
)

Class Implementation

change "isOpen" property to open and close the modal-video

import React from 'react'
import ReactDOM from 'react-dom'
import ModalVideo from 'next-modal-video'

class App extends React.Component {

  constructor () {
    super()
    this.state = {
      isOpen: false
    }
    this.openModal = this.openModal.bind(this)
  }

  openModal () {
    this.setState({isOpen: true})
  }

  render () {
    return (
      <React.Fragment>
        <ModalVideo channel='youtube' isOpen={this.state.isOpen} videoId='L61p2uyiMSo' onClose={() => this.setState({isOpen: false})} />
        <button onClick={this.openModal}>Open</button>
      </React.Fragment>
    )
  }
}

ReactDOM.render(
  <App />,
    document.getElementById('root')
)

Options

  • About YouTube options, please refer to https://developers.google.com/youtube/player_parameters?hl=en
  • About Vimeo options, please refer to https://developer.vimeo.com/apis/oembed
propertiesdefault
channel'youtube'
youtubeautoplay1
cc_load_policy1
colornull
controls1
disablekb0
enablejsapi0
endnull
fs1
h1null
iv_load_policy1
listnull
listTypenull
loop0
modestbrandingnull
originnull
playlistnull
playsinlinenull
rel0
showinfo1
start0
wmode'transparent'
theme'dark'
mute0
vimeoapifalse
autopausetrue
autoplaytrue
bylinetrue
callbacknull
colornull
heightnull
loopfalse
maxheightnull
maxwidthnull
player_idnull
portraittrue
titletrue
widthnull
xhtmlfalse
youkuautoplay1
show_related0
customurlMP4 URL / iframe URL
ratio'16:9'
allowFullScreentrue
animationSpeed300
classNamesmodalVideo'modal-video'
modalVideoClose'modal-video-close'
modalVideoBody'modal-video-body'
modalVideoInner'modal-video-inner'
modalVideoIframeWrap'modal-video-movie-wrap'
modalVideoCloseBtn'modal-video-close-btn'
ariaopenMessage'You just opened the modal video'
dismissBtnMessage'Close the modal by clicking here'

FAQ

How to track YouTube videos playing in modal-video by GA4?

  1. Enable JS API. Turn enablejsapi property to 1.
  2. Load YouTube Iframe API. Add <script src="https://www.youtube.com/iframe_api"></script> in HTML file.

Licence

[MIT]

FAQs

Package last updated on 06 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc