Code Monkey home page Code Monkey logo

react-youtube-lazyload's Introduction

React YouTube Lazyload

⚡ A blazing fast YouTube embed component that supports lazy loading.

NPM JavaScript Style Guide

React-YouTube-Lazyload

📦 Requirements

- React 16.8.0 or later

✨ Installation

npm install --save react-youtube-lazyload

(or)

yarn add react-youtube-lazyload

💡 Props

- videoId (Required): (string) The YouTube video ID.
- width (Optional): (number) Change the width of the player.
- height (Optional): (number) Change the height of the player.
- privacy (Optional): (boolean) Privacy Enhanced Mode
- playing (Optional): (boolean) Control the play/pause state of the video.
- className (Optional): (string) Additional CSS classname to apply to the YouTube component (Out of the box tailwindcss support).
- onPlayChange (Optional): (function) Callback function to be called when the play state changes. It receives a boolean argument indicating whether the video is playing or not.

🖊️ Usage

import React from 'react'
import { YouTube } from 'react-youtube-lazyload'
import 'react-youtube-lazyload/dist/index.css'

const App = () => {
  const [playing, setPlaying] = React.useState(false)
  return (
    <YouTube
      videoId='dQw4w9WgXcQ'
      privacy={true} // Privacy Enhanced Mode (optional) - default: false
      onPlayChange={(e) => setPlaying(e)}
      playing={playing}
      className='w-full h-96'
    />
    <button onClick={() => setPlaying(!playing)}>Play/Pause</button>
  )
}

export default App

💚 Message

I hope you find this project useful. If you have any questions, please create an issue.

License

MIT © mcnaveen

react-youtube-lazyload's People

Contributors

mcnaveen avatar

Stargazers

 avatar  avatar

Watchers

 avatar

react-youtube-lazyload's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.