code/tamagui.dev/data/docs/intro/installation.mdx
Use npm create tamagui@latest to pick one of our starter templates.
Tamagui 2 takes advantage of new style features in React Native 0.81+ including
boxShadow, filter, and more. On web, there are no version restrictions.
To install from scratch:
yarn add @tamagui/core
Core is just the style library. If you plan to use our full UI kit, you can
avoid installing @tamagui/core and instead:
yarn add tamagui
The tamagui package is a superset of core, so anywhere the docs reference
@tamagui/core, you can replace it with tamagui.
Next, you'll want to set up your configuration and
provide it with TamaguiProvider:
import { TamaguiProvider, View } from '@tamagui/core'
import config from './tamagui.config' // your configuration
export default function App() {
return (
<TamaguiProvider config={config} defaultTheme="light">
<View width={200} height={200} backgroundColor="$background" />
</TamaguiProvider>
)
}
We have a recommended preset configuration called @tamagui/config:
yarn add @tamagui/config
You can use it like so:
import { TamaguiProvider, createTamagui } from '@tamagui/core'
import { defaultConfig } from '@tamagui/config/v5'
// you usually export this from a tamagui.config.ts file
const config = createTamagui(defaultConfig)
type Conf = typeof config
// make imports typed
declare module '@tamagui/core' {
interface TamaguiCustomConfig extends Conf {}
}
export default () => {
return <TamaguiProvider config={config} defaultTheme="light"></TamaguiProvider>
}
And that's it!
<Preview> <DemoButton /> </Preview>import { Button } from 'tamagui'
export default function Demo() {
return <Button theme="blue">Hello world</Button>
}
From here, we recommend spending some time understanding configuration.
100% of Tamagui features work at both runtime and compile-time, which makes it both easy to use and fast. Because it works fully at runtime, and because we've invested a lot into building it such that it doesn't need any special bundler configuration to work on either native or web, you can begin using Tamagui with just the above setup.
Once you have Tamagui installed, you'll want to explore:
Later on, you can set up the compiler to gain more performance and some nice development helpers.
Tamagui generally doesn't require any special bundler setup as we've worked hard to make it "just work" without configuration in a wide variety of environments.
That said, the broader React Native and React Native Web ecosystem is filled with packages that do need configuration. Tamagui provides a variety of bundler plugins that help with that:
<Spacer /> <Grid gap="$4"> <LogoCard title="Next.js" img="/logos/next-js.svg" link="/docs/guides/next-js" subtitle="Full-featured React framework with great developer experience." colorOffset={2} /> <LogoCard title="Expo" img="/logos/expo.svg" link="/docs/guides/expo" subtitle="Platform for creating universal native apps with JavaScript and React." colorOffset={6} /> <LogoCard title="Vite" img="/logos/vite.svg" link="/docs/guides/vite" subtitle="Fast and modern development server and build tool." colorOffset={1} /> <LogoCard title="Webpack" img="/logos/webpack.svg" link="/docs/guides/webpack" subtitle="Powerful module bundler for modern JavaScript applications." colorOffset={0} /> <LogoCard title="Metro" img="/logos/metro.svg" link="/docs/guides/metro" subtitle="Fast, scalable, and serverless JavaScript bundler for React Native." colorOffset={3} /> <LogoCard title="One" img="/logos/one.svg" link="/docs/guides/one" subtitle="Universal React framework with native support." colorOffset={4} /> </Grid>