Overview
Tamagui is a complete universal UI kit built for both web and native apps. It includes @tamagui/core, which is a universal style system, and @tamagui/static, an optimizing compiler that works with core and tamagui. The goal of Tamagui is to allow developers to share more code between web and native apps while maintaining a high level of performance and code maintainability. It achieves this through an optimizing compiler that generates platform-specific optimizations and a “CSS-in-JS” style system that can flatten even inline styles with logic into flattened nodes. This results in significant runtime performance improvements.
Features
- Universal style system: Tamagui includes @tamagui/core, which is a style system that can be used for both web and native apps.
- Optimizing compiler: Tamagui also includes @tamagui/static, an optimizing compiler that works with core and tamagui. This compiler generates platform-specific optimizations and improves runtime performance.
- Flattening of styled components: The optimizing compiler can flatten a large percentage of styled components in your app, resulting in improved performance. It understands a rich “CSS-in-JS” style system and can flatten even inline styles with logic into flattened nodes.
- Atomic CSS and partially evaluated code: The compiler generates atomic CSS and partially evaluated code, which further enhances runtime performance.
- Easy contribution: Tamagui is a monorepo that makes it easy to contribute to the project.
Installation
To install Tamagui and set up a development environment, follow these steps:
Run the build watcher in a dedicated terminal:
# Run the build watcher npm run watch
Use the sandbox project to test and develop things for the web:
# Use the sandbox project for web development npm run sandbox:web
To test on native, use the kitchen-sink project:
# Use the kitchen-sink project for native testing npm run kitchen-sink
Create a development build:
# Create a development build npm run build:dev
Run the site in development mode to test if it works at runtime:
# Run the site in development mode npm run dev
If everything looks good, run the site with the compiler enabled:
# Run the site with the compiler enabled npm run dev:compiler
Finally, build the site for production and test it:
# Build the site for production npm run build
By following these steps, you can ensure that Tamagui works well with various environments and configurations, including Vite, Webpack, Metro, Next.js with SSR, and with the compiler both on and off. Integration tests will be added in the future to cover all combinations of environments.
Summary
Tamagui is a universal UI kit designed for both web and native apps. It includes a universal style system and an optimizing compiler that generates platform-specific optimizations. The compiler can flatten styled components and improves runtime performance by generating atomic CSS and partially evaluated code. Tamagui is easy to contribute to, and developers can set up a development environment by following the provided installation steps.