Components
The elements you build with, and what they render on each platform
Every Tamagui component takes style props. This page covers the base elements those props go on, and which one to use when.
View and Text
View and Text are the two primitives everything else is built on. They match
React Native’s View and Text and add the Tamagui style props on top:
Use them by default. A View is a flex column on every platform, so a layout you
build once looks the same on web and native. On web they render a div and a
span, and you can change the tag with render when
you need semantic HTML, such as <View render="nav">.
See View & Text for the full prop reference, including event handlers and the non-style props Tamagui adds.
Reusable components with styled()
styled() wraps any of the above into a named component with default styles
and typed variants. Inline props and styled() are both optimized by the
compiler, so pick whichever reads better:
Themes in the tree
Theme switches the theme for a subtree, and any component takes a theme
prop for the same thing at one level:
See Theme for ThemeUpdate, custom variables, and how
sub-themes resolve.
The UI kit
The tamagui package adds styled, accessible components on top of these
primitives: Button, Dialog, Sheet, Select, and the rest of the
UI kit. Every one of them accepts unstyled to drop its default
styles and keep only its behavior.
HTML elements
The html export has an element for each semantic HTML tag, such as
html.article, html.h1, and html.p. On web each one renders that tag, and on
native it renders the matching React Native primitive. It follows web and
React Strict DOM semantics, which
makes it a good fit for screens that are mostly web content, like docs,
marketing pages, and articles.
html.* is in early development. Its elements keep the browser’s default
display, so html.div is display: block on web, while React Native only
supports flex layout. A layout built from html.* can therefore look different
on native. Use View and Text when the same screen has to look the same
everywhere. See HTML elements for the element list
and native rules.
Prefer utility classes?
The same elements exist in @tamagui/tailwind, styled with className
instead of props. See Tailwind.