safearea

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package safearea reports the parts of a page covered by system UI (status bar, notch / Dynamic Island, home indicator, navigation bar) and follows their changes, e.g. on rotation.

in, err := safearea.Get(a)
safearea.OnChange(a, func(in safearea.Insets) { ... })

SyncPage mirrors the insets into every page as CSS variables on <html>:

--tango-safe-top, --tango-safe-bottom, --tango-safe-left, --tango-safe-right

for pages that cannot rely on env(safe-area-inset-*) (Android WebView, which reports 0 there, older engines, values needed in JS). Use them with env() as the fallback:

padding-top: var(--tango-safe-top, env(safe-area-inset-top, 0px));

Insets are in CSS pixels relative to the page's web view. On iOS a page fills the screen; the values matter once the page opts into viewport-fit=cover (otherwise WKWebView insets the content itself, and padding by them again would double it). The Android host keeps pages clear of system bars, so they are normally zero there.

Get returns ErrUnsupported on desktop and tango.ErrNotRunning after the app quit.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = platform.ErrUnsupported

Functions

func OnChange

func OnChange(a *tango.App, fn func(Insets))

OnChange calls fn on the main thread with the new insets whenever they change. It does nothing where the backend has no safe area.

func SyncPage

func SyncPage(a *tango.App) error

SyncPage keeps the --tango-safe-* CSS variables of every page current. Pages can also listen for the "tangosafearea" event on window, whose detail is {top, bottom, left, right}. Call it before creating surfaces (it adds a bridge script). It returns ErrUnsupported (and installs nothing) where the backend has no safe area.

Types

type Insets

type Insets = platform.Insets

Insets in CSS pixels.

func Get

func Get(a *tango.App) (Insets, error)

Get returns the current insets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL