Giter VIP home page Giter VIP logo

starters's Introduction

Tamagui

Style and UI for React (web and native) meet an optimizing compiler

NPM downloads Discord users online Commits per month


  • @tamagui/core - Universal style library for React.
  • @tamagui/static - Optimizing compiler that works with core and tamagui.
  • 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 - it turns styled components, even with complex logic or cross-module imports, into a simple div alongside atomic CSS on the web, or a View with its style objects hoisted on native.

The entirety of Tamagui works at compile time and runtime, and can be set up gradually, with initial usage as simple as importing it and using the base views and styled function.

We recommend checking out the starters with npm create tamagui@latest, they range from a simple learning example to a production-ready monorepo.

The compiler optimizes most and ultimately flattens a majority of styled components. In the ~500px² responsive browser section of the Tamagui website, 49 of the 55 or so inline styled components are flattened to a div. The homepage gains nearly 15% on Lighthouse with the compiler on.

Learn more on the website.

Installing Tamagui

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/v3'

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 v3 config imports the @tamagui/animations-css driver on web and @tamagui/animations-react-native on native. You can change these as you please, we provide exports for animationsCSS and animationsNative. If you want to use Reanimated, you can copy and paste this code and pass it as animations to createTamagui.

Usage

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>
  );
}

Contributing

To contribute to Tamagui reference the contributing guide.

To contribute to documentation reference the writing guide.

starters's People

Contributors

hirbod avatar ivopr avatar natew avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

starters's Issues

eas build hangs at the yarn install build phase

I am new to the Expo and eas world. I tried to run eas build on the starter but the build hangs and never completes. It either might be connected to yarn 3 or TypeScript version but I haven't found a solution yet.

Does anyone use eas and has a working config?

Cheers
Screenshot 2022-08-18 at 17 07 42

add storybook-react and storybook-react-native and jest tests to starter repo

Hi Guys,

I'd love to see Storybook for react and react-native as well as some Jest testing inside of the starter template. I am playing around to add it myself but especially with Storybook there seem to be some webpack config missing which is not intuitiv.

I think the best folder structure would be:

apps/expo
apps/nextjs
apps/react-storybook
apps/react-storybook-native

Error building next app

Running yarn build from the /next folder i'm getting this error:

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1033:15)
    at Module._compile (node:internal/modules/cjs/loader:1069:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Object.newLoader (/Users/matthieuh/workspace/perso/starters/next-expo-solito/node_modules/esbuild-register/dist/node.js:2262:9)
    at Object.extensions..js (/Users/matthieuh/workspace/perso/starters/next-expo-solito/node_modules/esbuild-register/dist/node.js:4801:24)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at ChildProcess.listener (/Users/matthieuh/workspace/perso/starters/next-expo-solito/node_modules/@tamagui/static/dist/cjs/extractor/getStaticBindingsForScope.js:68:13)

I'm trying to build next on this commit: 33e7fe0

[Bug][Native] User Detail Screen Link To Home Fails

Hi,

The < Go Home button fails to navigate to the homepage on native (I only tested on iOS). This could be a problem specific to solito.

Reproduction

  1. Clone the next-expo-solito starter
  2. Run yarn native
  3. Open the app in iOS
  4. Tap Link to user
  5. Attempt to go back Home using the < Go Home button

Possible Solution

Follow the same pattern used in the HomeScreen to create a link (using the useLink Hook):

export function UserDetailScreen() {
  const [id] = useParam('id')
  const homeLinkProps = useLink({
    href: '/',
  })

  return (
    <YStack f={1} jc="center" ai="center" space>
      <Paragraph ta="center" fow="800">{`User ID: ${id}`}</Paragraph>
      <Button {...homeLinkProps} icon={ChevronLeft}>
        Go Home
      </Button>
    </YStack>
  )
}

Typescript autocomplete is not working

Hi! I was trying this starter template, but can't get IntelliSense working. Haven't changed anything in the source code. Restarted typescript server to make sure it's working. 😕 Any ideas why that might be the case?

In this example, it shows me the default CSS colors:
Снимок экрана 2022-06-06 в 23 33 49

The same happens if I try to use Tamagui components directly. It accepts the correct types, but no luck with autocomplete.

New project fails to start both web and native

After running

npx create-tamagui-app@latest my-app
cd my-app
yarn web

I'm getting the following error message:

Cannot find module '/my-app/node_modules/@my/ui/dist/cjs'. Please verify that the package.json has a valid "main" entry

Update
Only after running yarn build, was I able to run the new project that isn't mentioned in the docs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.