Iframe

Iframe

IFrame is an HTML document which is embedded in another HTML doc on a web page. IFrames are used to insert content from another source.

With the Bootstrap integration, you can put the content of the IFrame inside modal to make it even more interactive and entertaining.

IFrames in Bootstrap are fully responsive components, adjusting accordingly to the screen size so there's no need to worry about the quality of your content.

Use examples:

  • Video tutorial
  • Promotional video presentation
  • Google Maps in contact section

See the following examples to get a good grip at IFrames.

Examples

Default Iframe example.

import React from "react";
import { CDBIframe, CDBContainer } from "cdbreact";
export const Iframe = () => {
return (
<CDBContainer>
<CDBIframe src="https://www.youtube.com/embed/xnczyP2jSR0"/>
</CDBContainer>
);
};

API

In this section you will find advanced information about the Iframe component. You will find out which modules are required, what are the possibilities of configuring the component, and what events and methods you can use to work with it.

Contrast Iframe Import Statement

You need to import the Contrast Iframe component first before using it.

import { CDBIframe } from "cdbreact";

API Reference: Contrast Iframe Properties

The table below shows the configuration options of the CDBIframe component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classesAdds custom classes<CDBIframe className="myClass" ... />
urlStringRequired. The iframe url<CDBIframe url="https://www.youtube.com/embed/xnczyP2jSR0" ... />
allowFullScreenBooleanfalseIf set, applies the allowFullScreen param<CDBIframe allowFullScreen .../>
heightNumberDefines component height<CDBIframe height={300} .../>
widthNumberDefines component width<CDBIframe width={300} .../>
idStringAdds id to the element<CDBIframe id="my_id" .../>
nameStringAdds name attribute<CDBIframe name="myIframe" .../>
onLoadfunctionFunction fired on onLoad event<CDBIframe onLoad={handleLoad} .../>
onMouseOutfunctionFunction fired on onMouseOut event<CDBIframe onMouseOut={handleEvent} .../>
onMouseOverfunctionFunction fired on onMouseOver event<CDBIframe onMouseOver={handleEvent} .../>
ratioStringDefines component ratio. Choose from "1by1", "4by3", "16by9" and "21by9"<CDBIframe ratio="1by1" .../>
sandboxStringAdds optional sandbox values: (no value) - Applies all restrictions, allow-forms - Allows form submission, allow-modals Allows to open modal windows, allow-orientation-lock Allows to lock the screen orientation, allow-pointer-lock Allows to use the Pointer Lock API, allow-popups Allows popups, allow-popups-to-escape-sandbox Allows popups to open new windows without inheriting the sandboxing, allow-presentation Allows to start a presentation session, allow-same-origin Allows the iframe content to be treated as being from the same origin, allow-scripts Allows to run scripts, allow-top-navigation Allows the iframe content to navigate its top-level browsing context, allow-top-navigation-by-user-activation Allows the iframe content to navigate its top-level browsing context, but only if initiated by user<CDBIframe sandbox .../>
titleStringDefines component title<CDBIframe title="my_title" .../>
styleObjectAdd's additional styles.<CDBIframe style={{color: 'red'}}.../>