Skip to main content

Overview

Uniwind provides device-specific CSS functions that automatically adapt to platform characteristics. These functions help you create responsive styles that work seamlessly across different devices and screen densities.
CSS functions must be defined as utilities in your global.css file before use. You cannot use them directly in className props with arbitrary values.

Available Functions

hairlineWidth()

Returns the thinnest line width that can be displayed on the device. Perfect for creating subtle borders and dividers. Define in global.css
Usage Example

fontScale()

Multiplies a base font size by the device’s font scale setting (accessibility setting). This ensures your text respects user preferences for larger or smaller text. Define in global.css
You can pass a numeric argument directly to fontScale() instead of wrapping it in calc():
Usage Example

pixelRatio()

Multiplies a value by the device’s pixel ratio. Useful for creating pixel-perfect designs that scale appropriately across different screen densities. Define in global.css
You can pass a numeric argument directly to pixelRatio() instead of wrapping it in calc():
Usage Example

light-dark()

Returns different values based on the current theme mode (light or dark). This function automatically adapts when the theme changes, making it perfect for creating theme-aware styles without manual theme switching logic. Define in global.css
Usage Example
The light-dark() function is particularly useful for maintaining color consistency across themes without needing separate CSS variables for each theme.
Inside a ScopedTheme, light-dark() follows the scoped theme, not the app’s theme (Uniwind 1.14.0+ and Uniwind Pro 1.10.0+; older versions always use the app’s theme).

platform-color()

Available in Uniwind 1.14.0+ and Uniwind Pro 1.10.0+ Uses a system color through React Native’s PlatformColor, with a fallback for other platforms and for web.
  • A name starting with ? or @ is an Android resource, such as ?attr/colorPrimary or @android:color/holo_blue_light
  • Any other name is an iOS semantic color, such as label or systemBlue
  • With two or more arguments, the last one is the fallback. It can be any color or a var()
Define in global.css
Usage Example
On a platform with no matching name, and on web, the fallback is the whole color. From React Native 0.88 the fallback is also passed to PlatformColor, so iOS uses it when a semantic color doesn’t exist. On Android, classes that use platform-color() are applied again after theme and OS appearance changes, so theme attributes and values-night colors stay in sync.
On Android, a resource that doesn’t exist throws and crashes the app on every React Native version, even with a fallback. Only use resources your app or Android provides.

min()

Available in Uniwind 1.10.0+ and Uniwind Pro 1.5.0+ Returns the smallest of its arguments. Use it to cap a size, for example a width that follows the screen but never grows past a fixed value. Define in global.css
Arguments can be px, rem, vw and vh lengths, plain numbers, and other functions such as max(), calc(), pixelRatio() and fontScale(). Percentages are not supported inside min(). min() is a standard CSS function, so it also works in arbitrary values:
max() works the same way and returns the largest of its arguments, for example min-h-[max(50vh,320px)].

CSS Parser

Learn about CSS variable support and custom CSS classes

Theming

Combine with themes for powerful styling