### Tamagui Installation and Next Steps
Source: https://tamagui.dev/docs/intro/installation
This snippet outlines the initial steps after installing Tamagui, guiding users to explore CLI tools, bundler setups, and design system creation. It also mentions the optional compiler setup for performance enhancements.
```jsx
import { View, Text, styled } from '@tamagui/core'
import { Heading } from './Heading'
const App = (props) => (
<>
Welcome to Tamagui!Once you have Tamagui installed, you’ll want to explore:CLI
- Command-line tools for building, optimizing, and
managing your Tamagui projects
Bundler Setup
- Integration guides for Next.js,
Expo, Vite, Webpack, Metro, and more
Design Systems
- Build your own optimized
component library with Tamagui
Later on, you can set up the compiler to gain
more performance and some nice development helpers.
Bundler Guides
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:
>
)
function k(a = {}) {
let { wrapper: e } = a.components || {}
return e ? } /> : g(a)
}
function l(a, e) {
throw new Error(`Expected ` + (e ? "component" : "object") + ` ``` + a + `` to be defined: you likely forgot to import, pass, or provide it.`)
}
return j(P);
})();
;return Component;
```
--------------------------------
### PortalProvider Setup
Source: https://context7_llms
Instructions on how to install and implement the PortalProvider at the root of your application.
```APIDOC
## PortalProvider
### Description
Provides a context for rendering portal content. When rendering into the root of the app, you need to install the `@tamagui/portal` package and add `PortalProvider` to your app's root.
### Installation
```bash
npm install @tamagui/portal
```
### Usage
```tsx fileName="App.tsx"
import { PortalProvider } from '@tamagui/portal'
import YourApp from './components/YourApp'
function App() {
return (
)
}
export default App
```
### Props
#### Query Parameters
- **shouldAddRootHost** (boolean) - Optional - Defines whether to add a default root host or not.
```
--------------------------------
### Dialog Installation and Setup
Source: https://context7_llms
Provides instructions for installing the Tamagui Dialog component. It can be used directly from `tamagui` or installed independently using npm. If installed independently, the `@tamagui/portal` package is also required, and `PortalProvider` must be added to the application's root.
```bash
npm install @tamagui/dialog
```
```bash
npm install @tamagui/portal
```
--------------------------------
### Expo Project Setup Commands
Source: https://tamagui.dev/docs/guides/expo
This snippet shows common commands for starting and running an Expo project. It includes commands for clearing the cache, running on Android, running on iOS, and starting the web version.
```bash
expo start -c
yarn expo run:android
yarn expo run:ios
expo start --web
```
--------------------------------
### Install react-native-teleport for Native Portal Setup
Source: https://tamagui.dev/docs/components/portal
This command installs the 'react-native-teleport' package, which is recommended for native environments to ensure React context is preserved when using portals. It's a crucial step before importing the setup module.
```bash
npm install react-native-teleport
```
--------------------------------
### NextThemeProvider Installation
Source: https://tamagui.dev/docs/guides/next-js
Install the necessary package for NextThemeProvider using yarn.
```APIDOC
## POST /api/users
### Description
This endpoint allows for the creation of a new user in the system. It accepts user details in the request body and returns the created user's information.
### Method
POST
### Endpoint
/api/users
### Parameters
#### Query Parameters
- **limit** (integer) - Optional - The maximum number of users to return.
#### Request Body
- **username** (string) - Required - The desired username for the new user.
- **email** (string) - Required - The email address of the new user.
- **password** (string) - Required - The password for the new user.
### Request Example
```json
{
"username": "johndoe",
"email": "john.doe@example.com",
"password": "securepassword123"
}
```
### Response
#### Success Response (200)
- **id** (integer) - The unique identifier for the created user.
- **username** (string) - The username of the created user.
- **email** (string) - The email address of the created user.
#### Response Example
```json
{
"id": 1,
"username": "johndoe",
"email": "john.doe@example.com"
}
```
```
--------------------------------
### Tamagui v5 Configuration Example (JSX)
Source: https://tamagui.dev/docs/core/config-v5
An example of Tamagui v5 configuration in JSX, demonstrating the structure and basic setup. It includes frontmatter with title and description, and a main component function that renders introductory paragraphs and installation instructions.
```jsx
var Component=(()=>{
var p=Object.create;
var s=Object.defineProperty;
var u=Object.getOwnPropertyDescriptor;
var g=Object.getOwnPropertyNames;
var k=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;
var f=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),v=(a,e)=>{
for(var t in e)s(a,t,{get:e[t],enumerable:!0})
};
var r=(a,e,t,l)=>{
if(e&&typeof e=="object"||typeof e=="function")
for(let i of g(e))
!N.call(a,i)&&i!==t&&s(a,i,{get:()=>e[i],enumerable:(l=u(e,i))||l.enumerable
});
return a
};
var y=(a,e,t)=>(
t(t=a!=null?p(k(a)):{}),
r(e||!a||!a.__esModule?s(t,"default",{value:a,enumerable:!0}):t,a)
);
var w=a=>r(s({},"__esModule",{value:!0}),a);
var o=f((C,d)=>{
d.exports=_jsx_runtime
});
var x={};
v(x,{default:()=>m,frontmatter:()=>b});
var n=y(o());
var b={
title:"Config v5",
description:"Modern config and themes with @tamagui/config/v5"
};
function h(a){
let e={"a":"a","code":"code","div":"div","h2":"h2","h3":"h3","hr":"hr","li":"li","ol":"ol","p":"p","pre":"pre","span":"span","strong":"strong","ul":"ul",...
a.components
};
let {IntroParagraph:t,Notice:l,PropsTable:i}=e;
t||c("IntroParagraph",!0),
l||c("Notice",!0),
i||c("PropsTable",!0)
;
return(0,n.jsxs)(n.Fragment,{
children:[
(0,n.jsx)(t,{
children:(0,n.jsx)(e.p,{children:`The recommended Tamagui configuration gives you a complete design system, flexible theme\ngeneration, Tailwind aligned shorthands, multiple animation drivers, and easy\ncustomization.`})
}),
"\n",
(0,n.jsxs)(e.p,{children:[
`V5 builds on v4 with more colors, theme helpers, and expanded media queries.\nMigration from v4 is straightforward - see\n`,
(0,n.jsx)(e.a,{href:"#whats-different-from-v4",children:"what’s changed"}),
"."
]}),
"\n",
(0,n.jsx)(e.p,{children:"First install the config package:"
}),
"\n",
(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:"language-bash",children:(0,n.jsxs)(e.div,{"data-line":"1",className:"highlight-line", "data-highlighted":"true",children:[
(0,n.jsx)(e.span,{className:"token function",children:"npm"}),
" ",
(0,n.jsx)(e.span,{className:"token function",children:"install"}),
` @tamagui/config\n`
```
--------------------------------
### Install Tamagui CLI
Source: https://tamagui.dev/docs/intro/installation
Use the Tamagui CLI to create a new project with a starter template. This command initiates the setup process for Tamagui.
```bash
npm create tamagui@latest
```
--------------------------------
### Tamagui CLI Build Command Examples (Terminal)
Source: https://tamagui.dev/docs/guides/next-js
Illustrates how to use the Tamagui CLI for targeted builds. Examples show how to specify individual files or use glob patterns with `--include` and `--exclude` options to optimize specific parts of the project before the Next.js build.
```bash
# Target specific files tamagui build --target web ./src/components/Button.tsx ./src/components/Card.tsx -- next build # Use glob patterns tamagui build --target web --include "src/components/**/*.tsx" --exclude "src/components/**/*.test.tsx" ./src -- next build
```
--------------------------------
### Setup PortalProvider in App (TypeScript)
Source: https://tamagui.dev/docs/components/popover
Example of how to import and include the PortalProvider component in your application's root file (e.g., App.tsx). This is necessary for independent Popover installations.
```tsx
import { PortalProvider } from '@tamagui/portal'
import YourApp from './components/YourApp'
function App() {
```
--------------------------------
### Installation and Native Setup
Source: https://tamagui.dev/docs/components/linear-gradient
Instructions for installing and setting up the linear-gradient package for native applications.
```APIDOC
## Installation and Native Setup
### Description
Guides users through the process of installing the `expo-linear-gradient` package and configuring it for use with Tamagui, including steps for projects without Expo.
### Method
N/A (Setup Guide)
### Endpoint
N/A (Setup Guide)
### Parameters
N/A
### Request Example
N/A
### Response
N/A
#### Step 1: Install expo-linear-gradient
```bash
npm install expo-linear-gradient
# or
yarn add expo-linear-gradient
```
#### Step 2: Import the setup module
```tsx
// tamagui.config.ts
import { config } from '@tamagui/core'
import 'expo-linear-gradient'
export default config({
// ... your other configurations
})
```
#### Without expo-linear-gradient
For projects not using Expo, you might need to manually link or configure native dependencies. Refer to the `expo-linear-gradient` documentation for specific instructions.
```
--------------------------------
### Setup Native Menus and ContextMenus with Zeego
Source: https://context7_llms
Integrates platform-native context menus for Menu and ContextMenu components using Zeego. Requires installing several packages and importing the Zeego setup module.
```bash
npm install zeego @react-native-menu/menu react-native-ios-context-menu react-native-ios-utilities sf-symbols-typescript
```
```tsx
// App.tsx - before any Tamagui imports
import '@tamagui/native/setup-zeego'
// Then use the `native` prop:
```
--------------------------------
### Native Toast Setup
Source: https://tamagui.dev/docs/components/toast
Instructions for installing and importing the native toast setup module for Tamagui to enable native toasts on iOS and Android using the Burnt library.
```APIDOC
## Native Toast Setup
### Description
To enable native toasts on iOS and Android using the Burnt library, you need to install the native dependency and import the setup module in your application.
### Installation
Use your preferred package manager:
**Yarn:**
```bash
yarn add burnt
```
**NPM:**
```bash
npm install burnt
```
**Bun:**
```bash
bun add burnt
```
**PNPM:**
```bash
pnpm add burnt
```
### Import
Add the following import statement to your `App.tsx` file *before* any Tamagui imports:
```typescript
import '@tamagui/native/setup-burnt'
```
### Rebuild App
After adding the import, rebuild your React Native application. Without this setup, toasts will still function but the `native` prop will not have any effect on mobile platforms.
### Anatomy
The core components for toasts are:
```jsx
```
```
--------------------------------
### Install react-native-teleport for Native Portal Setup
Source: https://tamagui.dev/docs/components/portal
This snippet shows how to install the react-native-teleport package using various package managers. This is the recommended approach for setting up portals on native platforms to ensure React context is preserved.
```bash
yarn add react-native-teleport
```
```bash
npm install react-native-teleport
```
```bash
bun add react-native-teleport
```
```bash
pnpm add react-native-teleport
```
--------------------------------
### Install NextThemeProvider with Yarn
Source: https://tamagui.dev/docs/guides/next-js
This command installs the necessary package for the NextThemeProvider. It's a straightforward installation process using the yarn package manager.
```bash
yarn add @tamagui/next-theme
```
--------------------------------
### Tamagui Stripped Down Configuration Example
Source: https://tamagui.dev/docs/core/configuration
A minimal example of a Tamagui configuration file, illustrating core concepts for beginners. This serves as a starting point for understanding Tamagui's configuration structure.
```typescript
import { defaultConfig } from '@tamagui/config/v5'
import { createTamagui } from 'tamagui'
export const config = createTamagui({
...defaultConfig,
// Add your custom configurations here
})
```
--------------------------------
### Install @tamagui/native Package
Source: https://context7_llms
Installs the @tamagui/native package, which provides setup utilities for native integrations. This should be imported at the app's entry point before any Tamagui imports.
```bash
npm install @tamagui/native
```
--------------------------------
### Tamagui Provider Setup Example (TSX)
Source: https://tamagui.dev/docs/components/portal
This code snippet illustrates the setup of TamaguiProvider, a core component for configuring the Tamagui environment within an application. It shows how to wrap the application's root with TamaguiProvider to enable theme management and other global configurations. This is essential for ensuring all Tamagui components function correctly.
```tsx
import { TamaguiProvider } from 'tamagui';
// ... other imports and component definitions
{/* Your application content here */}
```
--------------------------------
### Install and Use PortalProvider for Root Rendering
Source: https://tamagui.dev/ui/sheet/1.59.0
Guide to installing the `@tamagui/portal` package and integrating `PortalProvider` into your application's root for rendering components at the root level instead of inline. This is necessary for specific rendering scenarios.
```bash
yarn add @tamagui/portal
```
```bash
npm install @tamagui/portal
```
```bash
bun add @tamagui/portal
```
```bash
pnpm add @tamagui/portal
```
```typescript
import { PortalProvider } from '@tamagui/portal' import YourApp from './components/YourApp' function App() { return ( ) } export default App
```
--------------------------------
### TamaguiProvider Setup Example (JSX)
Source: https://tamagui.dev/docs/core/configuration
This snippet demonstrates the basic structure for setting up TamaguiProvider in a React application. It includes essential configurations like 'config' and wraps child components.
```jsx
import { TamaguiProvider, View } from 'tamagui'
export default function App() {
return (
{' '}
<TamaguiProvider{' '}
config={
config
}>
{' '}
<View{' '}
margin='
$sm
'{' '}
/>
{' '}
</TamaguiProvider>)
)
}
```
--------------------------------
### Install Reanimated for Tamagui
Source: https://tamagui.dev/docs/core/animations-reanimated
Installs the `@tamagui/animations-reanimated` and `react-native-reanimated` packages using Yarn. Ensure you follow the official Reanimated installation guide for platform-specific setup.
```bash
yarn add @tamagui/animations-reanimated react-native-reanimated
```
--------------------------------
### Toast Examples
Source: https://context7_llms
Examples demonstrating various ways to customize and position toast viewports, handle mobile safe areas, use different viewports, and pass custom data.
```APIDOC
## Toast Examples
### Position the viewport
To position the viewport on native toasts:
- iOS (burnt): Supports top or bottom placements. Adjustable by passing `from` to `burntOptions`:
```tsx
```
- Android (burnt): Not supported.
- Web (Notification API): Not supported.
To position the viewport on custom toasts:
You should change the positioning of your [``](#toastviewport). For instance, if you want them to appear from top right:
```tsx
```
Or for bottom center:
```tsx
```
When using multiple toasts, you can change the order of toasts by setting
`flexDirection` to `column` or `column-reverse`. Or even have them stack horizontally
using `row` or `row-reverse`.
### Mobile safe area
To show toasts inside device's safe area, install `react-native-safe-area-context` if you haven't, wrap your app inside ``, and then use the safe area insets to position the viewport inside the safe area.
```tsx
import { useSafeAreaInsets } from 'react-native-safe-area-context'
const SafeToastViewport = () => {
const { left, top, right } = useSafeAreaInsets()
return (
)
}
```
### Different viewports
To send toasts to different viewports, you can set up different viewports:
```tsx
const App = () => {
return (
{/* default viewport */}
)
}
```
And then, use the viewport's name on the toasts.
```tsx
const MyComponent = () => {
return // default viewport
}
const MyComponent2 = () => {
return
}
```
### Custom data
Just pass your custom data to the second parameter of the `show()` method.
```ts
const toastController = useToastController()
top.toastController.show('Title', { myPreset: 'error' }) // or top.toastController.show("Title", { customData: { myPreset: 'error' } })
```
then, when showing the toast, you can retrieve them like so:
```ts
const toastState = useToastState()
top.toastState.myPreset // or top.toastState.customData.myPreset
```
To add TypeScript auto-completion for your custom fields, you can use TS module augmentation:
```ts
declare module '@tamagui/toast' {
interface CustomData {
myPreset: 'error' | 'success' | 'warning'
}
}
```
### Without hooks
You can also use toasts without the hooks.
You can't use native toasts this way.
#### Single Toast
```tsx
export default () => {
const [open, setOpen] = React.useState(false)
const timerRef = React.useRef(0)
React.useEffect(() => {
return () => clearTimeout(timerRef.current)
}, [])
return (
Subscribed!We'll be in touch.
)
}
```
```
--------------------------------
### Theme Toggle with useThemeSetting
Source: https://tamagui.dev/docs/guides/next-js
Example of how to use the `useThemeSetting` hook to get the current theme and toggle between themes in a React component.
```APIDOC
## PUT /api/users/{id}
### Description
This endpoint updates an existing user's information. It requires the user's ID in the path and the fields to update in the request body.
### Method
PUT
### Endpoint
/api/users/{id}
### Parameters
#### Path Parameters
- **id** (integer) - Required - The unique identifier of the user to update.
#### Request Body
- **username** (string) - Optional - The new username for the user.
- **email** (string) - Optional - The new email address for the user.
### Request Example
```json
{
"email": "john.doe.updated@example.com"
}
```
### Response
#### Success Response (200)
- **id** (integer) - The unique identifier for the updated user.
- **username** (string) - The updated username of the user.
- **email** (string) - The updated email address of the user.
#### Response Example
```json
{
"id": 1,
"username": "johndoe",
"email": "john.doe.updated@example.com"
}
```
```
--------------------------------
### Get RNW Stylesheet
Source: https://tamagui.dev/docs/guides/next-js
Retrieves the stylesheet for react-native-web components. This is specifically noted as necessary if you are using react-native-web components within your Tamagui setup.
```javascript
const rnwStyle = StyleSheet.getSheet();
```
--------------------------------
### Install and Configure NextThemeProvider for SSR Themes
Source: https://tamagui.dev/docs/guides/next-js
This section details how to install and set up the `@tamagui/next-theme` package for managing SSR light/dark themes. It assumes your themes are named 'light' and 'dark', but this can be overridden. The example shows the necessary imports and configuration within `_app.tsx`.
```bash
yarn add @tamagui/next-theme
```
```tsx
import { NextThemeProvider, useRootTheme } from '@tamagui/next-theme'
import { AppProps } from 'next/app'
import Head from 'next/head'
export default function MyApp({ Component, pageProps }: AppProps) {
return (
)
}
```
--------------------------------
### Tamagui Configuration Example (v5)
Source: https://tamagui.dev/docs/core/configuration
A basic example of a Tamagui configuration file using the v5 preset. It demonstrates how to extend the default configuration with custom media queries.
```typescript
import { defaultConfig } from '@tamagui/config/v5'
import { createTamagui } from 'tamagui'
export const config = createTamagui({
...defaultConfig,
media: {
...defaultConfig.media,
// add your own media queries here, if wanted
},
})
type OurConfig = typeof config
declare module 'tamagui' {
interface TamaguiCustomConfig extends OurConfig {}
}
```
--------------------------------
### Basic Tamagui Button Component in Next.js Page
Source: https://tamagui.dev/docs/guides/next-js
A simple 'Hello world' example demonstrating the usage of a Tamagui `Button` component within a Next.js page. This requires the `tamagui` library to be installed and configured.
```typescript
'use client' import { Button } from 'tamagui' export default function Home() { return }
```
--------------------------------
### Tamagui CLI Usage Examples
Source: https://tamagui.dev/docs/intro/compiler-install
Various command-line examples for using the `tamagui build` command, demonstrating how to build for different targets, specific files, include/exclude patterns, and verify optimizations.
```bash
# Build all components in a directory (web + native by default)
npx tamagui build ./src
```
```bash
# Build for web only
npx tamagui build --target web ./src
```
```bash
# Build for native only
npx tamagui build --target native ./src
```
```bash
# Build a specific file
npx tamagui build ./src/components/MyComponent.tsx
```
```bash
# Include/exclude patterns
npx tamagui build --include "components/**" --exclude "**/*.test.tsx" ./src
```
```bash
# Verify minimum optimizations (useful in CI)
npx tamagui build --target web --expect-optimizations 10 ./src
```
--------------------------------
### Installation
Source: https://context7_llms
Instructions for installing the Popover and PortalProvider packages.
```APIDOC
## Installation
Popover is already installed in `tamagui`, or you can install it independently:
```bash
npm install @tamagui/popover
```
### PortalProvider
When rendering into root of app instead of inline, you'll first need to install the `@tamagui/portal` package:
```bash
npm install @tamagui/portal
```
Then add `PortalProvider` to the root of your app:
```tsx fileName="App.tsx"
import { PortalProvider } from '@tamagui/portal'
import YourApp from './components/YourApp'
function App() {
return (
)
}
export default App
```
```
--------------------------------
### Configure Tamagui with v5 Presets (TypeScript)
Source: https://tamagui.dev/docs/core/animation-drivers
Demonstrates how to configure Tamagui using the v5 presets, which offer pre-configured animations for all four drivers. This example shows importing necessary functions and presets, and exporting the final configuration.
```tsx
import { defaultConfig } from '@tamagui/config/v5'
import { animations } from '@tamagui/config/v5-css' // or v5-motion, v5-rn, v5-reanimated
import { createTamagui } from 'tamagui'
export const config = createTamagui({
...defaultConfig,
animations,
})
```
--------------------------------
### Button Usage Examples
Source: https://context7_llms
Examples demonstrating how to use the Tamagui Button component, including basic usage, sizing, and icon theming.
```APIDOC
## Button Usage
### Description
Examples demonstrating how to use the Tamagui Button component.
### Method
N/A (Component Usage)
### Endpoint
N/A (Component Usage)
### Parameters
None
### Request Example
```json
{
"example": "N/A"
}
```
### Response
#### Success Response (200)
N/A (Component Usage)
#### Response Example
```json
{
"example": "N/A"
}
```
### Basic Usage
```tsx
import { Button } from 'tamagui'
export default () =>
```
### Sizing
Sizing buttons provides a unique challenge especially for a compiler, because you need to adjust many different properties - not just on the outer frame, but on the text wrapped inside. Tamagui supports adjusting the padding, border radius, font size and icons sizes all in one with the `size` prop.
```tsx
import { Button } from 'tamagui'
export default () =>
```
Given your theme defines a size `6`, the button will adjust all of the properties appropriately. You can also pass a plain number to get an arbitrary size.
### Icon Theming
You can pass icons as either elements or components. If passing components, Tamagui will automatically pass the `size` and `color` prop to them based on your theme.
You can [use the source of Button itself](https://github.com/tamagui/tamagui/blob/v2/code/ui/button/src/Button.tsx) to see in more detail what variants you can override, and how we use this pattern internally to create our Button component.
```
--------------------------------
### Install Tamagui Portal for Standalone Dialog
Source: https://tamagui.dev/docs/components/dialog
If using `@tamagui/dialog` independently without the main `tamagui` package, you must also install `@tamagui/portal`. This is necessary for managing the modal's rendering context.
```bash
yarn add @tamagui/portal
npm install @tamagui/portal
bun add @tamagui/portal
pnpm add @tamagui/portal
```
--------------------------------
### useToastState Example (TypeScript)
Source: https://tamagui.dev/docs/components/toast
A TypeScript code example demonstrating the usage of the `useToastState` hook to get the current toast state.
```tsx
const {
toast
} = useToastState()
```
--------------------------------
### Install Next.js Theme Package
Source: https://tamagui.dev/docs/guides/next-js
Command to install the @tamagui/next-theme package, which provides SSR light/dark theme support for Next.js applications.
```bash
yarn add @tamagui/next-theme
```
--------------------------------
### Select Installation (Bash)
Source: https://context7_llms
Provides the command to install the Tamagui Select component independently using npm.
```bash
npm install @tamagui/select
```
--------------------------------
### Setup Native LinearGradient with Expo
Source: https://context7_llms
Integrates `expo-linear-gradient` for high-performance native gradient rendering. Requires installing the package and importing the setup module.
```bash
npm install expo-linear-gradient
```
```tsx
// App.tsx - before any Tamagui imports
import '@tamagui/native/setup-expo-linear-gradient'
```
--------------------------------
### Install Portal Package for Root Rendering
Source: https://context7_llms
Instructions for installing the Portal package, which is necessary when rendering Popovers into the root of the application instead of inline. This enables global positioning and management of the Popover content.
```bash
npm install @tamagui/portal
```
--------------------------------
### Configure Multiple Animation Drivers (TSX)
Source: https://tamagui.dev/docs/core/animation-drivers
This example demonstrates configuring multiple animation drivers, 'createCSS' and 'createSpring', at the root level of the Tamagui configuration. It shows how to import different animation packages and combine them. This allows for selecting different animation drivers on a per-component basis using the 'animatedBy' prop.
```tsx
import { createAnimations as createCSS } from '@tamagui/animations-css'
import { createAnimations as createSpring } from '@tamagui/animations-motion'
export default createTamagui({
animations: {
default: createSpring(),
lazy: createCSS()
}
})
```
--------------------------------
### Install Tamagui CLI (Bash)
Source: https://tamagui.dev/docs/guides/next-js
Installs the Tamagui CLI as a development dependency using Yarn. This command is essential for optimizing Tamagui builds in production environments. Ensure you have Yarn installed or adapt the command for npm or pnpm.
```bash
yarn add -D @tamagui/cli
```
--------------------------------
### PortalProvider Installation
Source: https://tamagui.dev/ui/popover/1.83.0
Instructions for installing and using the PortalProvider when rendering popovers into the root of the app.
```APIDOC
## PortalProvider Installation
### Description
When rendering into root of app instead of inline, you'll first need to install the `@tamagui/portal` package.
### Installation
```bash
# Using Yarn
yarn add @tamagui/portal
# Using npm
npm install @tamagui/portal
# Using Bun
bun add @tamagui/portal
# Using pnpm
pnpm add @tamagui/portal
```
### Usage
Then add `PortalProvider` to the root of your app:
```tsx
// App.tsx
import { PortalProvider } from '@tamagui/portal'
import YourApp from './components/YourApp'
function App() {
return (
)
}
export default App
```
### Props
#### shouldAddRootHost
- **type**: boolean
- **description**: Defines whether to add a default root host or not.
```
--------------------------------
### Install @tamagui/next-plugin with Yarn
Source: https://tamagui.dev/docs/guides/next-js
This command installs the optional Tamagui plugin for Next.js projects that do not use Turbopack. This plugin helps streamline certain configuration settings.
```bash
yarn add @tamagui/next-plugin
```
--------------------------------
### Installing Tamagui Group Package
Source: https://context7_llms
Provides the command to install the Tamagui Group package independently using npm. This is useful if you are not using the full Tamagui monorepo setup.
```bash
npm install @tamagui/group
```
--------------------------------
### Native Portal Setup
Source: https://context7_llms
Instructions for setting up native portals using react-native-teleport to preserve React context.
```APIDOC
## Native Portal Setup (Recommended)
### Step 1: Install react-native-teleport
```bash
npm install react-native-teleport
```
### Step 2: Import the setup module
In your app's entry file (index.js or App.tsx), before any Tamagui imports:
```tsx
import '@tamagui/native/setup-teleport'
```
This setup ensures that React context is automatically preserved for portaled content on native platforms.
```
--------------------------------
### Tamagui Button Component Example (JSX)
Source: https://tamagui.dev/docs/intro/compiler-install
A basic example of the Tamagui Button component. This snippet is incomplete but shows the start of a Button tag, implying its usage for interactive elements.
```jsx