UIPackage React Native
Search
Menu

Order Summary

Order review section with item content, subtotal, shipping, discounts, tax and a clearly labeled total.

Choose a base, then select Add to order to see the summary.

Install

First install? Set up the registry in your app.

npx --yes --package=https://native.uipkge.dev/cli/uipkge-native-0.1.1.tgz uipkge-native add order-summary

Source files

Expand a file to read the source the installer copies into your app.

components/blocks/order-summary/OrderSummary.tsx
import * as React from 'react'
import { View, type ViewProps } from 'react-native'
import { Text } from '@/components/ui/text'
import { cn } from '@/lib/utils'

export interface OrderSummaryProps extends ViewProps {
  className?: string
  title?: string
  /** Authored order lines belong here, above the price breakdown. */
  children?: React.ReactNode
  /** Amounts from the consumer's order system, already formatted for its locale and currency. */
  subtotal?: string
  shipping?: string
  discount?: string
  tax?: string
  total: string
  labels?: Partial<Record<'subtotal' | 'shipping' | 'discount' | 'tax' | 'total', string>>
  action?: React.ReactNode
}

export function OrderSummary({
  className,
  title = 'Order summary',
  children,
  subtotal,
  shipping,
  discount,
  tax,
  total,
  labels,
  action,
  ...props
}: OrderSummaryProps) {
  return (
    <View {...props} className={cn('gap-[16px] rounded-lg border border-border bg-card p-[16px]', className)}>
      <Text size="lg" accessibilityRole="header" className="font-semibold text-card-foreground">
        {title}
      </Text>
      {children}
      <View className="gap-[8px]">
        {subtotal ? (
          <View className="flex-row flex-wrap justify-between gap-x-[12px]">
            <Text size="sm" variant="muted" className="shrink">
              {labels?.subtotal ?? 'Subtotal'}
            </Text>
            <Text size="sm" className="shrink text-card-foreground" style={{ fontVariant: ['tabular-nums'] }}>
              {subtotal}
            </Text>
          </View>
        ) : null}
        {shipping ? (
          <View className="flex-row flex-wrap justify-between gap-x-[12px]">
            <Text size="sm" variant="muted" className="shrink">
              {labels?.shipping ?? 'Shipping'}
            </Text>
            <Text size="sm" className="shrink text-card-foreground" style={{ fontVariant: ['tabular-nums'] }}>
              {shipping}
            </Text>
          </View>
        ) : null}
        {discount ? (
          <View className="flex-row flex-wrap justify-between gap-x-[12px]">
            <Text size="sm" variant="muted" className="shrink">
              {labels?.discount ?? 'Discount'}
            </Text>
            <Text size="sm" className="shrink text-card-foreground" style={{ fontVariant: ['tabular-nums'] }}>
              {discount}
            </Text>
          </View>
        ) : null}
        {tax ? (
          <View className="flex-row flex-wrap justify-between gap-x-[12px]">
            <Text size="sm" variant="muted" className="shrink">
              {labels?.tax ?? 'Tax'}
            </Text>
            <Text size="sm" className="shrink text-card-foreground" style={{ fontVariant: ['tabular-nums'] }}>
              {tax}
            </Text>
          </View>
        ) : null}
        <View className="flex-row flex-wrap justify-between gap-x-[12px] border-t border-border pt-[12px]">
          <Text className="shrink font-semibold text-card-foreground">{labels?.total ?? 'Total'}</Text>
          <Text className="shrink font-semibold text-card-foreground" style={{ fontVariant: ['tabular-nums'] }}>
            {total}
          </Text>
        </View>
      </View>
      {action}
    </View>
  )
}
components/blocks/order-summary/index.ts
export { OrderSummary, type OrderSummaryProps } from './OrderSummary'

Dependencies

Registry items

Browse shopping and reservations