Skip to content
portalbits
Home Docs GitHub(opens in a new tab)

Guides

Get startedFoundationsMotion

Components

All components

Buttons

ButtonIconButton

Inputs

InputSelectTextareaSlider

Selection

CheckboxToggleToggleGroupSwitchRadioGroup

Identity

AvatarBadge

Overlays

DialogPopoverTooltipDropdownMenuAlertDialog

Disclosure

TabsAccordion

Cards

AppCardArticleCardFeatureCard

Content

CarouselSectionHeaderEmptyStateAlertProgressSeparatorRowListRow

Chrome

PortalShellSidebarNavMobileNavTopBarAuthFrameColorSelectorFloatingNav

FloatingNav

A white pill bar. Narrow widths open the same links in a menu panel.

Home
Docs
GitHub
Variations
More examples

Narrow width with Menu

Below 640px of component width, Menu opens the same links.

Home
Docs

Source

<script lang="ts">
  import 'portal-bits/styles.css';
  import 'portal-bits/tokens.css';
  import type { Snippet } from 'svelte';

  let { children }: { children: Snippet } = $props();
</script>

{@render children()}
<script lang="ts">
  import FloatingNavExample from './FloatingNavExample.svelte';
</script>

<FloatingNavExample actions={true} />
<script lang="ts">
  import { FloatingNav } from 'portal-bits';
  let { actions = true }: { actions?: boolean } = $props();
</script>

{#snippet brand()}<a href="#home">Home</a>{/snippet}
{#snippet items()}<a href="#docs" aria-current="page">Docs</a>{/snippet}
{#snippet links()}<a href="https://github.com/AddeyX/portal-bits">GitHub</a>{/snippet}

<FloatingNav label="Example" {brand} {items} actions={actions ? links : undefined} />

API reference

These tables list the props and snippets that FloatingNav declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.

Props

NameTypeDefaultRequiredBindingDescription
labelstringNoneYesOne-wayNames the `nav` landmark.
openbooleanfalseNoBindableWhether the narrow-width menu is open.

Snippets

NameTypeDefaultRequiredBindingDescription
brandSnippetNoneYesOne-wayThe leading mark, usually a home link.
itemsSnippetNoneYesOne-wayThe middle links. Each destination is one anchor.
actionsSnippetNoneNoOne-wayAn optional trailing group, such as a repository link.

Forwarded attributes

None. FloatingNav forwards no attributes.

No data attributes are documented as stable.

Limits

  • Below 640px of component width the links move into a Menu panel. The 640px threshold is an adaptation.
  • Escape and an outside pointer press close the menu. Both are adaptations. The source site did not close on Escape.
  • Focus trapping and scroll locking are not provided.
  • The Menu and Close button text is English text inside the component.

Related

  • TopBar
  • PortalShell
Previous ColorSelector

On this page

  • Preview
  • Source
  • API reference
  • Props
  • Snippets
  • Forwarded attributes
  • Limits