This component root is based on the <div> element and can take in any additional HTML attributes. In addition, the <iframe> attributes can be passed to the component to customize the video embed as well through the iframeAttrs prop. The following are the custom props that can be passed to the component.
Prop
Type
Default
source *
The source of the video. E.g. `https://www.youtube.com/embed/lJIrF4YjHfQ`
string
—
iframeAttrs
Additional attributes to pass to the iframe element.
HTMLAttributes<'iframe'>
—
Accessibility
The <VideoEmbed> component has some accessibility considerations baked into it. The following are some of the key accessibility features that are included in the component and worth considering:
There is a hidden skip link prior to the embed that allows users to skip past the video and its controls. This is done by using a visually hidden hash link that only displays on keyboard focus and is linked to an empty div immediately after the video embed.
Depending on the framework, it’s sometimes beneficial to use a component. In this case, we have put together the following Astro component to serve as a blueprint for how you could possibly set up a Video Embed component, and what properties to consider.