navigation

Floating Menu

A floating interaction menu with a GSAP timeline animation, featuring a cross-trigger and staggered split-text reveals.


Installation

Install the component

Run the following command to install the component and its dependencies:
npx @motion-core/cli add floating-menu

Import the component

Import the component into your Svelte file:
import { FloatingMenu } from "$lib/motion-core";
import { FloatingMenu } from "$lib/motion-core";

Usage

Due to the nature of the component, testing in full-screen mode is recommended.

<script lang="ts">
	import { FloatingMenu } from "motion-core";
	import motionCoreLogo from "$lib/assets/motion-core-logo.svg?raw";

	const menuGroups = [
		{
			title: "Platform",
			variant: "muted" as const,
			links: [
				{ label: "Home", href: "#" },
				{ label: "Components", href: "#" },
				{ label: "Showcase", href: "#" },
			],
		},
		{
			title: "Resources",
			variant: "default" as const,
			links: [
				{ label: "Documentation", href: "#" },
				{ label: "API Reference", href: "#" },
				{ label: "Community", href: "#" },
			],
		},
		{
			title: "Company",
			variant: "muted" as const,
			links: [
				{ label: "About Us", href: "#" },
				{ label: "Blog", href: "#" },
				{ label: "Careers", href: "#" },
				{ label: "Contact", href: "#" },
			],
		},
	];
	let demoContainer: HTMLElement;
</script>

<div
	bind:this={demoContainer}
	class="relative flex h-full min-h-150 w-full scale-[1] transform items-center justify-center overflow-hidden p-4"
>
	<p class="text-center font-display">
		Due to the nature of the component, testing in full-screen mode is
		recommended.
	</p>
	<FloatingMenu
		portalTarget={demoContainer}
		{menuGroups}
		primaryButton={{ label: "Get Started", href: "#" }}
		secondaryButton={{ label: "Log In", href: "#" }}
	>
		{#snippet logo()}
			<a href="/" class="flex items-center">
				<span
					class="inline-flex shrink-0 items-center text-accent [&>svg]:h-3 [&>svg]:w-8 [&>svg]:fill-current"
					aria-hidden="true"
				>
					{@html motionCoreLogo}
				</span>
			</a>
		{/snippet}
	</FloatingMenu>
</div>

Props

FloatingMenu

PropTypeDefault
menuGroups
MenuGroup[] []
logo
Snippet undefined
primaryButton
MenuButton undefined
secondaryButton
MenuButton undefined
portalTarget
HTMLElementstring "body"
class
string ""

MenuGroup

KeyTypeDefault
title
string
variant
"default""muted" "default"
links
MenuLink[] []

MenuLink

KeyTypeDefault
label
string
href
string

MenuButton

KeyTypeDefault
label
string
href
string