Components

ForeignObject

A themed native SVG foreignObject primitive. Render it inside Svg or an appropriate SVG parent.

Props

Native attributes and event handlers are forwarded to the underlying foreignObject element unless handled by the component.

PropTypeDefaultDescription
children Snippet undefined Content snippet rendered by the component.
class string '' Tailwind classes merged with the theme and variants.
element SVGForeignObjectElement | null null Bindable reference to the underlying DOM element.
inTransition TransitionProps undefined Overrides the opening transition.
isVisible boolean true Bindable visibility state.
outTransition TransitionProps undefined Overrides the closing transition.
theme Theme global theme Optional local theme override.
transition TransitionProps [noopTransition, {}] A Svelte transition function and its options.
variants string[] [] Local variant names or theme references such as button.base.

Default usage

Import ForeignObject from sveltewind/components. This example shows its default styling in a usable context.

HTML content inside SVG.
+page.svelte
Loading...

Examples

Theme variants

Every variant available for ForeignObject in the built-in themes is shown below.

clip — Apply the clip variant.

HTML content inside SVG.
+page.svelte
Loading...

visible — Apply the visible variant.

HTML content inside SVG.
+page.svelte
Loading...

accent — Apply the accent variant.

HTML content inside SVG.
+page.svelte
Loading...

Class overrides

Apply text-rose-500 opacity-75 locally.

HTML content inside SVG.
+page.svelte
Loading...

Props and behavior

Change x, y, width, height while retaining the default component styling.

HTML content inside SVG.
+page.svelte
Loading...

Content and values

Provide different text, child content, or definitions inside the required parent context.

Your project content
+page.svelte
Loading...