The Despia runtime measures the device’s hardware screen corner radius at page load and exposes it to your web app as a JavaScript value and a CSS variable. Use it to make modals, sheets, cards, and overlays curve in lockstep with the physical bezel.Documentation Index
Fetch the complete documentation index at: https://setup.despia.com/llms.txt
Use this file to discover all available pages before exploring further.
This feature requires no scheme call. The runtime injects
despia.screenRadius and the --screen-radius CSS variable automatically at page load on every supported device.Installation
- Bundle
- CDN
How it works
Two values are injected before your stylesheets and scripts run.window.screenRadius is a JavaScript number in CSS pixels representing the device’s top-left corner radius. --screen-radius is the same value exposed as a CSS variable with a px unit, scoped to the document root.
The radius resolves to 0 on devices without rounded screens, on older OS versions, and in non-Despia environments, so any code that consumes the value degrades cleanly without runtime checks.
Concentric inner corners with calc()
When an inner element sits inset from the screen edge, its corner radius must shrink by the same inset to stay concentric with the bezel. Combine the variable withcalc() and the inset distance.
0px fallback is non-negotiable. Without it, the calc() resolves to calc(- 8px) in a non-Despia browser and the rule is rejected, leaving the corner unrounded. With the fallback, the math evaluates to -8px, CSS clamps that to 0px, and the element renders square in browser previews while curving correctly inside the app.
Edge-pinned elements
For elements pinned to one edge of the screen, such as a top sheet, a docked toolbar, or a status banner, apply the calc only to the corners that touch the bezel and use a fixed radius for the inner corners.Reading the value in JavaScript
Gate any logic that depends on a real measurement behind the canonical platform check, and always default to0 when the value is missing.
isDespiaIOS or isDespiaAndroid only if a downstream calculation in your app already depends on platform-specific tuning.
Combining with safe areas
Concentric corners and safe area insets stack naturally. The element’s horizontal margin drives the corner math because the bezel curve meets the element on its left and right edges, while the top and bottom safe areas push the element inward without changing the geometry the corners are tracking.Resources
NPM Package
despia-native