@tamagui/core
- Universal style library for React.@tamagui/static
- Optimizing compiler that works withcore
andtamagui
.tamagui
- UI kit that adapts to every platform.
See tamagui.dev for documentation.
Tamagui lets you share more code between web and native apps without sacrificing the two things that typically suffer when you do: performance and code quality.
It does this with an optimizing compiler that outputs platform-specific optimizations, turning even cross-module-imported, logic-infused, inline-styled components into clean, flat DOM + CSS on the web, or on native, hoisted style objects and View/Text. The compiler is also optional, as Tamagui also works entirely at runtime.
For example, within the ~500px² responsive browser section on the homepage, 49 of the 55 or so inline styled components are flattened to a div
. The homepage gains nearly 15% on Lighthouse just by turning on the compiler.
To install Tamagui with all its components run:
npm install tamagui @tamagui/config
Next, create a Tamagui config file named tamagui.config.ts
:
import { config } from '@tamagui/config/v2'
import { createTamagui } from 'tamagui'
const tamaguiConfig = createTamagui(config)
// this makes typescript properly type everything based on the config
type Conf = typeof tamaguiConfig
declare module 'tamagui' {
interface TamaguiCustomConfig extends Conf {}
}
export default tamaguiConfig
// depending on if you chose tamagui, @tamagui/core, or @tamagui/web
// be sure the import and declare module lines both use that same name
Note: The v2
config imports the css driver on web and react-native on native. For react-native, import the @tamagui/config/v2-native
config, and for reanimated, import the @tamagui/config/v2-reanimated
config.
To use Tamagui in your Expo or Next.js projects, all you need to do is wrap your application in the TamaguiProvider
:
// this provides some helpful reset styles to ensure a more consistent look
// only import this from your web app, not native
import '@tamagui/core/reset.css'
import { TamaguiProvider } from 'tamagui'
import tamaguiConfig from './tamagui.config'
export default function App() {
return (
<TamaguiProvider config={tamaguiConfig}>
{/* your app here */}
</TamaguiProvider>
)
}
Done! Now try out some components:
import { Button, Text } from 'tamagui'
function Example() {
return (
<Button>
<Text>My button</Text>
</Button>
);
}
We're welcoming and glad to have contributions to Tamagui. If you would like to contribute to Tamagui please check out our contributing guide for how to do so. If you would like to contribute to the Tamagui documentation, then please read our writing guide
If these kinds of contributions don't suit your style, you can always contribute by writing articles, making videos or joining our discord and helping other people solve problems.