Skip to main content

Video

Important information:
This component requires documentation.

YouTube video

<div class="ons-video">
  <iframe class="ons-video__iframe" src="https://www.youtube.com/embed/_EGJlvkgbPo" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
{% from "components/video/_macro.njk" import onsVideo %}
{{
    onsVideo({
        "youtubeUrl": "https://www.youtube.com/embed/_EGJlvkgbPo"
    })
}}
{%- macro onsVideo(params) -%}
    <div class="ons-video">
        {% if params.youtubeUrl is defined and params.youtubeUrl %}
            <iframe class="ons-video__iframe" src="{{ params.youtubeUrl }}" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
        {% endif %}
    </div>
{%- endmacro -%}
.ons-video {
  @extend .ons-u-mb-m;

  height: 0;
  padding-bottom: 56.25%; /* 16:9 */
  position: relative;

  &__iframe {
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
  }
}

Help improve this component

Let us know how we could improve this component or share your user research findings. Discuss the ‘Video’ component on GitHub