Functions & Directives
Overview
Nativewind allows the same functions and directives as Tailwind CSS. Please refer to the Tailwind CSS documentation.
These functions can be used within your theme, arbitrary class names, or within your custom CSS.
In addition to the functions and directives provided by Tailwind CSS, Nativewind polyfills the following CSS functions:
var()
var()
is a CSS function that allows you to use the value of a custom property (sometimes called a "CSS variable") inside the value of another property.
calc()
CAUTION
Support for calc()
is limited and will be improved in the future.
calc()
is a CSS function that allows you to perform calculations when specifying CSS property values. It can be used to perform addition, subtraction, multiplication, and division and can be used with other CSS functions such as var()
Limitations
Mixing Units
On the web, calc()
is a powerful tool that allows you to perform calculations with multiple units. However, React Native's layout engine is more limited and does not support mixing units. As a result, Nativewind only supports calc()
in two modes: numerical
and percentage
.
Custom Properties
Nativewind does not support operations in custom properties. Instead, you can use calc()
with custom properties by first defining the custom property and then using calc()
to perform the operation.
Looking to contribute? We're looking for contributors to help improve support for calc()
in Nativewind, such as adding support for other modes (e.g deg
)
env()
env()
is a CSS function that allows you to access device specific environment information.
Nativewind supports:
Please see Safe Area Insets for more information.