Command palette

@yasinsensoy/native

React Native · APIs and utilities

Utilities

Converts any CSS color string (hex, rgb, hsl, oklch) to an rgba() string React Native understands.

6 exports

Import

import {
  toNativeColor,
  withAlpha,
  openLink,
  useCurrentPath,
  useReducedMotion,
} from "@yasinsensoy/native";

Converts 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).

toNativeColor(input: string): string

withAlpha

function

Multiplies the color's alpha by a factor: same result as bg-primary/10 on web (withAlpha(colors.primary, 0.1)).

withAlpha(color: string, factor: number): string

Path 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.

useCurrentPath(): string | null

The "reduce motion" preference; animations do not play while it is on.

useReducedMotion(): boolean

Function handling an in-app address: navigates and returns true if it recognizes the address. Navigator registers itself here.

type LinkHandler = (href: string) => boolean