Installation
Get Tamagui set up, step by step
We recommend using npm create to set up one or more of the example apps via npm create tamagui
. It's useful even if integrating into an existing app.
Install
You can use the 0-dependency (outside of react itself) @tamagui/core
, or move higher level with tamagui
, which is a superset of core adding many components and hooks. We recommend yarn in general because it works well with both monorepos and React Native. Still, pnpm and npm work well too.
For just the core style library:
yarn add @tamagui/core
If you want tamagui
, you can avoid core and just:
yarn add tamagui
Add TamaguiProvider
at the root of your app and you are fully set up:
// optional but recommended CSS reset:import '@tamagui/core/reset.css'import { TamaguiProvider, View } from '@tamagui/core'export default () => (<TamaguiProvider><View width={200} height={200} backgroundColor="red" /></TamaguiProvider>)
Tamagui doesn't require any bundler setup for either web or native.
Typically you'll want to set up a few things with createTamagui
though - for example media queries, or custom fonts.
The configuration documentation covers this in detail, but if you'd like to get started quick with some decent defaults we have @tamagui/config
:
import { TamaguiProvider, createTamagui } from '@tamagui/core'import { config } from '@tamagui/config/v3'// you usually export this from a tamagui.config.ts fileconst tamaguiConfig = createTamagui(config)// make TypeScript type everything based on your configtype Conf = typeof tamaguiConfigdeclare module '@tamagui/core' {interface TamaguiCustomConfig extends Conf {}}export default () => {return (<TamaguiProvider config={tamaguiConfig}>{/* your app here */}</TamaguiProvider>)}
You should be ready to use any component:
import { Button } from 'tamagui'export default function Demo() {return <Button>Hello world</Button>}
From here, we'd recommend spending some time understanding configuration. Tamagui works 100% the same at runtime as at compile-time, so you can wait until you're needing some extra performance to set up the compiler.
Guides
Tamagui generally doesn't require any special bundler setup, but React Native Web and the ecosystem of React Native packages often do. Tamagui provides a variety of plugins for compatibility and simplifying compiler setup.
We also have more in-depth guides:
Webpack
Powerful module bundler for modern JavaScript applications.
Metro
Fast, scalable, and serverlessr javaScript bundler for react Native.
Vite
Fast and modern development server and build tool.
Expo
Platform for creating universal native apps with JavaScript and React.
Next.js
Full-featured React framework with great developer experience.
Previous
Introduction
Next
Introduction