Extends YStack, set to position="absolute" and inset={0} with zIndex below Header/Footer.
Props
unstyled
boolean
Removes all default Tamagui styles.
Source
v2-look Card: theme background over the unstyled @tamagui/ui Card behavior (structural layout + the size mechanism for size-derived radius and Header/Footer padding). Statics: Card.Header, Card.Footer, Card.Background. This is the exact source the registry ships — copy it into your app and the examples above import from your copy.
components/tamagui/Card.tsx
// Styled Card = the unstyled @tamagui/ui Card behavior (structural layout) +
// the default v2-look skin (theme background) and the size table: size-derived
// radius on the frame, size-derived padding on Header/Footer. Single skin
// definition; the shadcn registry item is generated from this file.
import {
CardBackground,
CardFooter as CardFooterBehavior,
CardFrame as UiCardFrame,
CardHeader as CardHeaderBehavior,
} from '@tamagui/card'
import {
type ComponentSize,
createStyledContext,
type GetProps,
styled,
withStaticProperties,
} from '@tamagui/core'
export type CardSize = ComponentSize | boolean
const CardContext = createStyledContext<{ size?: CardSize }>({ size: 'md' })
const cardRadius = {
xs: { borderRadius: 'sm' },
sm: { borderRadius: 'md' },
md: { borderRadius: 'md' },
lg: { borderRadius: 'md' },
xl: { borderRadius: 'lg' },
} as const
const cardPadding = {
xs: { padding: '2' },
sm: { padding: '3' },
md: { padding: '4' },
lg: { padding: '6' },
xl: { padding: '8' },
} as const
export const CardFrame = styled(UiCardFrame, {
displayName: 'Card',
context: CardContext,
backgroundColor: 'background',
variants: {
size: {
...cardRadius,
true: cardRadius.md,
},
} as const,
defaultVariants: {
size: 'md',
},
})
export const CardHeader = styled(CardHeaderBehavior, {
displayName: 'CardHeader',
context: CardContext,
variants: {
size: {
...cardPadding,
true: cardPadding.md,
},
} as const,
defaultVariants: {
size: 'md',
},
})
export const CardFooter = styled(CardFooterBehavior, {
displayName: 'CardFooter',
context: CardContext,
variants: {
size: {
...cardPadding,
true: cardPadding.md,
},
} as const,
defaultVariants: {
size: 'md',
},
})
export const Card = withStaticProperties(CardFrame, {
Header: CardHeader,
Footer: CardFooter,
Background: CardBackground,
})
export type CardProps = GetProps<typeof CardFrame>
Dependencies
yarn add @tamagui/card @tamagui/core
Expects theme tokens: background.
Need raw behavior without any skin? tamagui/unstyled re-exports the @tamagui/ui primitives (advanced).