An iframe component that syncs with the parent document's theme and template content. Use when needing to render dynamically generated or isolated content.
Supplies the iframe with Elements themes, utilities, fonts, and component registrations through its head template. Use this structure because iframe documents do not inherit resources from the parent document.
The iframe grows and shrinks with its content. Browsers that support native responsive iframe sizing use frame-sizing: content-height and window.requestResize(). If native sizing is unavailable or the document cannot use it, the component uses resize messages. The component handles both paths without changes to your templates.
Synchronizes the iframe height with expandable content so the host layout avoids empty space or internal scrollbars. Use for previews whose intrinsic height changes after interaction.
<nve-iframe sandbox="allow-scripts" aria-label="Dynamic height iframe example" style="--border: 1px solid red">
<template slot="head">
<title>Dynamic iframe height</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@nvidia-elements/themes/dist/bundles/index.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@nvidia-elements/themes/dist/fonts/inter.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@nvidia-elements/styles/dist/bundles/index.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@nvidia-elements/core/dist/bundles/index.min.js"></script>
</template>
<template>
<nve-accordion behavior-expand>
<nve-accordion-header>
<h2 nve-text="heading xs medium" slot="prefix">Dynamic height in iframe</h2>
</nve-accordion-header>
<nve-accordion-content>
The iframe expands when this content opens and contracts when it closes.
</nve-accordion-content>
</nve-accordion>
</template>
</nve-iframe>
Dynamic iframe height
Dynamic height in iframe
The iframe expands when this content opens and contracts when it closes.
Fixed Size
Set --width and --height to keep a fixed viewport with either sizing path.
Overrides intrinsic iframe dimensions with --width and --height to create a stable preview viewport. Use when you need to inspect embedded content at a fixed size regardless of its rendered bounds.
Space-separated native iframe sandbox permissions. The empty default applies all restrictions.Removing the attribute restores the empty default. Changes reload the iframe document.Include allow-scripts for automatic sizing and live theme synchronization.Combining allow-scripts and allow-same-origin permits access to the parent origin.
SandboxDescriptionstring
Use explicit sandbox permissions to enable only the capabilities your content needs.
Trusted preview with explicit sandbox permissions.
Complete Document
Complete HTML document rendered without the template wrapper, theme synchronization,or automatic sizing. Set explicit dimensions with --width and --height.Unset this property to restore the head and body templates. An empty string renders a blank document.
SrcdocDescriptionstring
Release Status
All elements and features go through 3 phases of stability, pre-release, beta and stable.
pre-release
Docs PreviewAPI DocumentationFully Themeable
beta
Robust unit test coveragesPassed API ReviewPassed Designer VQA ReviewIncluded in library package
stable
No known outstanding AA WCAG issuesNo known outstanding performance issuesAdapts to different screen/container sizesNo breaking API changes for at least 90 days