Tamagui 1.0 released with core, compiler and UI kit updates
Tamagui has reached version 1.0. The project is a cross-platform styling and UI system for React Native and web, built around an optimizing compiler that evaluates code at build time to produce flatter view trees and atomic CSS.
Tamagui is made up of three parts:
- Tamagui Core (
@tamagui/core): a style library supporting the full React Native API surface while depending only on React. - Tamagui Static (
@tamagui/static): an optimizing compiler on top of Core that uses partial evaluation, CSS extraction and tree-flattening. - Tamagui UI (
tamagui): a component kit built on Core's theme primitives.
Core changes
Since beta, Core has received over a thousand bugfixes plus performance and memory improvements. It supports React Native 0.70, React 18 and React Native Web 18. For 1.0, @tamagui/core no longer depends on react-native, so web-only projects do not need bundler aliasing and can skip react-native-web, which the post says saves roughly 30Kb. Core now generates its own styles, and the useTheme and useMedia hooks were optimized, with useMedia moving to React's useSyncExternalStore.
Other additions include <FontLanguage /> for per-language fonts, a face option for font configurations, a themeShallow prop, the loadTheme and updateTheme helpers, and the useMediaPropsActive hook. The styled factory can now wrap any component that accepts a style prop, and the team recommends adding as const after variants objects.
Compiler changes
@tamagui/static supports Webpack, Vite, Next, React Native and Expo via plugins. Average parse time has dropped below 6ms for a longer file, the compiler is now thread-safe, and it can optimize styled() definitions outside a separate design system package. Tamagui now works with Vite 3 and 4 through @tamagui/vite-plugin.
UI kit changes
New components include Sheet, Select, Dialog, AlertDialog, Slider, Card, ListItem, Avatar, Spinner and Progress. Label was updated, Group was split into XGroup and YGroup, and ScrollView is now exported. AlertDialog is the first component with a native prop that uses platform-native alerts on iOS and Android.
Other updates
- A new
@tamagui/animations-react-nativedriver alongside the CSS and Reanimated drivers. - Early support for React Server Components when
ENABLE_RSCis set. react-native-web-lite, a modernized react-native-web released as a temporary measure.@tamagui/next-themeand_activesub-themes pluscolor1tocolor12values in@tamagui/theme-base.- A
code/kitchen-sinkdemo app and improvements tocreate-tamagui.
Upcoming work listed includes container queries, a tamagui build command, more native prop support, and components such as <Tabs /> and <Accordion />. Sponsors get early access to the upcoming Studio, a realtime editor for colors, themes, tokens and default styles.
Example
import { FontLanguage, Text } from 'tamagui' // or '@tamagui/core'
export default () => (
<FontLanguage body="mandarin">
<Text fontFamily="$body">{/* TODO hello world in mandarin */}</Text>
</FontLanguage>
)
Links
Source: tamagui.dev