Skip to content

feat: add a floating variant to NavigationBar - #2

Draft
raajnadar wants to merge 1 commit into
mainfrom
feat/floating-navigation-bar
Draft

raajnadar wants to merge 1 commit into
mainfrom
feat/floating-navigation-bar

Conversation

@raajnadar

Copy link
Copy Markdown
Member

Draft. Parked. Do not merge.

This PR adds variant="floating" to NavigationBar: a 64dp capsule that floats over the content, with an icon for each destination. MD3 has no floating navigation bar, and @rootnative/components follows MD3. The code belongs to the planned glass component family, in its own package. This PR keeps the code, and CI builds and checks it until that package exists.

What it adds

  • variant?: 'docked' | 'floating' on NavigationBar. The default is 'docked', the bar as before.
  • The floating capsule: 64dp high, at most 480dp wide, a 16dp gap to each side and to the bottom of the window, surfaceContainer, full corners, elevation level 3.
  • Each destination shows its icon only. The label is the screen-reader name. The active indicator fills the destination.
  • The bar places itself at the bottom of its parent and reads the insets from a SafeAreaProvider:
    • It floats over a bottom inset of 40dp or less, which holds only a gesture handle.
    • It stays 16dp above a taller bottom inset, which holds the Android navigation buttons.
    • The side insets are added to the 16dp gap.
  • NavigationItem gets a 'floating' placement, so the capsule reuses the item, the state layer, the badge and the focus ring of the docked bar.
  • NavigationBarProps becomes a type alias. The type rejects labelVisibility, labelStyle and insetBottom on the floating bar.
  • A "Floating" frame on the example screen, a docs section, the CHANGELOG entry, the llms.txt text, and NavigationBarVariant in api-surface.json.

Why it is parked

  • MD3 has no floating navigation bar. The Compose navigation bar is docked (NavShape = CornerNone). The nearest MD3 surface is the floating toolbar, which is for actions, not for destinations.
  • A floating capsule tab bar is the iOS 26 pattern. It belongs with the planned glass components.
  • In components, the type alias breaks an interface that extends NavigationBarProps. A separate component in the glass package does not need that change.

Open before it can ship

  1. Move it out of components into the glass package, as its own component and not as a variant. Revert the NavigationBar union.
  2. Make the shared behavior a public API that both packages can use: the item, the state layer, the Space key on a tab, the pointerEvents table and the focus ring. Today these are internal to components.
  3. Decide the values that do not come from MD3: elevation level 3 (the MD3 floating toolbar is level 0, or level 1 beside a FAB), the 6dp end padding (the toolbar uses 8dp), the 480dp maximum width, the 40dp inset rule, and the icon-only items (MD3 recommends a text label on each destination).
  4. Shrink on scroll, not in this PR: a scrollOffset that moves the capsule between 64dp and 48dp after 24dp of scroll in one direction. The capsule is full at the top, and it keeps its size through the iOS bounce at the end of the content.
  5. The glass material. expo-glass-effect draws the native glass only on iOS 26 and later. Android, web and older iOS need a material of their own.
  6. In @rootnative/inertia: useHideOnScroll must start again when its offset source changes, for example on a tab switch.

Checks

  • 11 new tests in NavigationBar.test.tsx, a floating row in both elevation tables, and a prop passthrough case. Each new check fails when its fault is put into the source.
  • Passed locally: all 1778 Jest tests (native and web), tsc on components, lint, docs:check, registry:check and Prettier.
  • Not run locally, so CI must show them: the build, api:check, check:singletons, check:worklets, and the example typecheck against the built dist. api-surface.json was edited by hand.
  • Nobody has looked at the capsule on a device or in a browser yet.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant