Iframe

A cool and fancy Iframe that can make your life easier and also looks good.

Import
the javascript logo
import { Iframe } from "@schukai/monster/source/components/layout/iframe.mjs";
Source
the git logo
Package
the npm logo
Since
3.76.0

Introduction

The monster-iframe component wraps an iframe with Monster layout styling and sizing behavior. It is useful for embedding internal pages or tools while keeping a consistent layout shell.

Configuration

Provide the target URL through the src option. You can also set standard iframe attributes such as sandbox, loading, and referrerPolicy via options.

Responsive Behavior

The component observes its own size and adjusts the iframe height to fit the available space. This makes it suitable for split panels or resizable containers.

Simple Iframe

A basic iframe embedding an internal documentation page. The component adjusts its height to the available space and supports standard iframe options.

Javascript

import '@schukai/monster/source/components/layout/iframe.mjs';

const iframe = document.createElement('monster-iframe');

iframe.setOption('src', '/foundations.typography.html');
iframe.setOption('loading', 'lazy');

document.body.appendChild(iframe);

HTML

<div id="iframe-simple"></div>

Stylesheet

/** no additional stylesheet is defined **/

Component Design

The iframe is rendered inside a Shadow DOM wrapper for consistent styling. The exported part allows customization of the outer container.

Exported Parts

  • control: Wrapper around the iframe element.

monster-iframe::part(control) {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

HTML Structure

<monster-iframe></monster-iframe>

JavaScript Initialization

const element = document.createElement('monster-iframe');
document.body.appendChild(element);

Exported

Iframe

Derived from

CustomElement

Options

The Options listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the CustomElement.

Option
Type
Default
Description
templates
object
Template definitions
templates.main
string
undefined
Main template
labels
object
undefined
Label definitions
actions
object
Callbacks
actions.click
string
throw Error
features
object
Features
features.allowFullScreen
boolean
true
features.allowPaymentRequest
boolean
true
features.replaceTargets
boolean
true
me
loading
string
eager
referrerPolicy
string
no-referrer
src
string
Source
classes
object
undefined
CSS classes
disabled
boolean
false

  • since
  • deprecated

Properties and Attributes

The Properties and Attributes listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits Properties and Attributes from these parent classes. If you cannot find a specific Properties and Attributes in this list, we recommend consulting the documentation of the CustomElement.

  • data-monster-options: Sets the configuration options for the collapse component when used as an HTML attribute.
  • data-monster-option-[name]: Sets the value of the configuration option [name] for the collapse component when used as an HTML attribute.

Methods

The methods listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the CustomElement.

Static methods

[instanceSymbol]()
Returns
  • {symbol}
This method is called by the instanceof operator.
getCSSStyleSheet()
Returns
  • {CSSStyleSheet[]}
getTag()
Returns
  • {string}

Lifecycle methods

Lifecycle methods are called by the environment and are usually not intended to be called directly.

[assembleMethodSymbol]()
Returns
  • {Components.Layout.Iframe
Events
  • monster-iframe-clicked
connectedCallback()
Returns
  • {void}
This method is called by the dom and should not be called directly.
disconnectedCallback()
Returns
  • {void}
This method is called by the dom and should not be called directly.

Events

The component emits the following events:

  • monster-iframe-clicked

For more information on how to handle events, see the mdn documentation.

The current width of the area is too small to display the content correctly.