Styling
Guides how to choose a styling library in Lynx and build static CSS layouts.
In Lynx, choose between Vanilla Extract or Tailwind CSS v4 that suits your project.
Both methods generate CSS at build time and can be applied to the className of native <view> and <text>.
- Vanilla Extract: Write typed styles and Crispy tokens in
.css.ts. - Tailwind CSS v4: Combine utility classes in
className.
First check the build environment requirements and installation settings in the chosen guide. For theme configuration, see Theming.
For static layouts, apply classes from the zero-runtime styling library you're using to native <view> instead of Box, HStack, VStack.
As the number of repeated items increases, the rendering and style transformation cost of Layout components can accumulate.
Why we recommend static CSS
Box, HStack, VStack interpret style props at render time and transform tokens and aliases to create an object passed to <view style={...}>. This JavaScript processing and component rendering cost is separate from the layout work where the Lynx engine calculates the actual size and position of elements.
When you create static styles as CSS at build time with Vanilla Extract and Tailwind v4, you can skip the Layout component's prop interpretation and style object creation when applying classes to native <view>.
The engine's work of applying CSS and calculating layout is not entirely eliminated.
How is it different from web React?
Layout components in web React also interpret props at runtime. The web implementation passes CSS variables to predefined classes, and the browser applies the CSS. The current Lynx implementation directly constructs supported style props as a style object and passes it. This does not mean there is no cost in React or that Layout components don't work in Lynx.
ReactLynx's initial rendering constructs the first screen on the main thread and executes components on the background thread. Style transformation in the rendering path can be included in this initial work, so we recommend expressing static layouts with CSS generated at build time. Especially on screens with many repeated items, you can reduce unnecessary component and style transformation costs. The actual performance difference varies depending on the screen and runtime environment.
For properties determined at runtime, such as measured values or continuously changing values, pass only the necessary parts via inline style.
Recommended way to write
Check the configuration and writing examples in the guide for the library you're using.