<tap-page>

The page layout of mobile apps, with header and footer slots, safe area insets and pull-to-refresh. Content scrolls in the page itself and runs under the header and footer, padding keeps it clear of them. Don't add another scroll container, use scrollElement instead.

Example

import '@mantou/tap-ui/elements/page';
import '@mantou/tap-ui/elements/navbar';
import '@mantou/tap-ui/elements/content';

const onRefresh = ({ detail: done }: CustomEvent<() => void>) => {
  fetchData().then(done);
};

html`
  <tap-page refreshable @refresh=${onRefresh}>
    <tap-navbar slot="header" title="Chats"></tap-navbar>
    <tap-content>...</tap-content>
    <tap-tabbar slot="footer" .items=${tabs}></tap-tabbar>
  </tap-page>
`;

Use floatheader to overlay the header on the content, the navbar stays transparent until the content scrolls.

API

TapPageElement

Content scrolls in the page itself and runs under the header and footer; padding keeps it clear of them, so height: 100% children fill the area between the bars. Don't add another scroll container, use scrollElement instead. Absolutely positioned children ignore that padding and end up under the bars, so keep them in flow or inside an in-flow wrapper.

Shadow DOM; Extends TapVisibleBaseElement

TapPageElement Instance Properties

Property(Attribute) Reactive Type Description
floatheader(floatheader) Yes boolean Header overlays content; navbar stays transparent until content scrolls
You need to manually handle the top safe area inset for the page content.
refreshable(refreshable) Yes boolean Enable pull-to-refresh on the main scroll area
loading(loading) Yes boolean
disableNavigation(disable-navigation) Yes boolean
trackVisibility(track-visibility) Yes boolean
pullThreshold(pull-threshold) Yes number
refresh Emitter<() => void> Fired when pull exceeds the threshold.
Call detail() (done) when loading finishes so the indicator can dismiss.
navigationGesture Emitter<{ pan?: PanEventDetail; swipe?: SwipeEventDetail; end?: PointerEvent }>
get scrollElement HTMLElement | undefined The scroll container of the page content, e.g. to keep a chat scrolled to the bottom
get contentHeight number Measures the bars directly, the main insets are only set after the first resize observation

TapPageElement Other

Type Value
Event refresh, navigation-gesture
Slot header, footer
Part main, refresh
CSS State dim, fullscreen

TapVisibleBaseElement

Extends GemElement

TapVisibleBaseElement Instance Properties

Property(Attribute) Reactive Type Description
show Emitter
hide Emitter
fullShow Emitter Fired when the element becomes visible and entirely within the viewport,
e.g. a page whose enter animation has finished.
intersectionRoot Yes Element | Document
intersectionRootMargin Yes string
trackVisibility(track-visibility) Yes boolean
delay(delay) Yes number

TapVisibleBaseElement Other

Type Value
Event show, hide, full-show
CSS State visible, full-visible