React Native · APIs and utilities
Utilities
Converts any CSS color string (hex, rgb, hsl, oklch) to an rgba() string React Native understands.
Import
toNativeColor
functionConverts any CSS color string (hex, rgb, hsl, oklch) to an rgba() string React Native understands. Unparsable text is returned as is (e.g. "transparent", platform colors).
withAlpha
functionMultiplies the color's alpha by a factor: same result as bg-primary/10 on web (withAlpha(colors.primary, 0.1)).
openLink
functionOpens an address (counterpart of href on web). In order:
- If it is an in-site path like
/products/3or the app's deep link prefix,Navigatoris asked; if a route matches it navigates to that screen (without going to the system link opener). - Otherwise it opens in the system (
Linking.openURL): browser, phone, email.
Addresses like javascript: are never opened. Returns false silently if it cannot be opened.
Examples
useCurrentPath
functionPath of the focused screen ("/products/3"): produced by Navigator when the route defines a path; null if not defined or there is no Navigator. Counterpart of usePathname on web; Sidebar finds the active item with it.
useReducedMotion
functionThe "reduce motion" preference; animations do not play while it is on.
LinkHandler
typeFunction handling an in-app address: navigates and returns true if it recognizes the address. Navigator registers itself here.