v0.1 public beta early access on GitHub
Home / Screens / ecommerce-promo-codes
Screen template

Promo Codes Screen

Manual code entry plus coupon rows — tracked-out code, offer, terms, and expiry — with per-row Apply and a grayed 'Used & expired' section

pro Expo Go ✓ iosandroid gestures: tap · scroll haptics: light · selection · success
$ npx lumioui add ecommerce-promo-codes
import { PromoCodesScreen } from "@/screens/ecommerce/promo-codes";
Registry dependencies5
Native packages installed6
@lumioui/ui@latest@lumioui/core@latestreact-native-safe-area-context@*react-native-reanimated@*react-native-svg@*nativewind@*
ecommerce/promo-codes.tsxsource · yours to edit
import * as React from "react";
import { useState } from "react";
import { View, ScrollView } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Badge, Button, Glass, Icon, Input, Text } from "@lumioui/ui";
import { cn, useHaptic } from "@lumioui/core";

import { BLOCK_STAGGER, LumioMark, Mount, Press, ROW_STAGGER, ROW_STAGGER_CAP } from "../shared";
export interface PromoCode {
  code: string;
  /** "20% off orders over $150" — the offer in one line. */
  title: string;
  /** Big stub value on the ticket — "20%", "FREE", "$10". */
  value: string;
  /** Terms — "Min. spend $150 · One per order". */
  detail?: string;
  /** "Ends Sep 30" — omitted for evergreen codes. */
  expiresAt?: string;
  /** Already redeemed — renders grayed under "Used & expired". */
  used?: boolean;
}

export interface PromoCodesScreenProps {
  codes?: PromoCode[];
  /** Code applied to the current cart, if the host already has one. */
  appliedCode?: string;
  onApply?: (code: PromoCode) => void;
  /** Manual entry at the top — gets the raw string, not a PromoCode. */
  onEnter?: (code: string) => void;
  onBack?: () => void;
}

const DEFAULT_CODES: PromoCode[] = [
  {
    code: "SAVE20",
    value: "20%",
    title: "off orders over $150",
    detail: "Min. spend $150 · One per order",
    expiresAt: "Ends Sep 30",
  },
  {
    code: "FREESHIP",
    value: "FREE",
    title: "express shipping",
    detail: "Any order · No minimum",
    expiresAt: "Ends Oct 15",
  },
  {
    code: "KNIT15",
    value: "15%",
    title: "off knitwear",
    detail: "Ponchos, sweaters & cardigans",
  },
  {
    code: "WELCOME10",
    value: "$10",
    title: "off your first order",
    detail: "Min. spend $50",
    expiresAt: "Expired Sep 5",
    used: true,
  },
];

function PromoRow({
  code,
  applied,
  onApply,
}: {
  code: PromoCode;
  applied: boolean;
  onApply?: (c: PromoCode) => void;
}) {
  const haptics = useHaptic();
  return (
    <View
      className={cn(
        "flex-row overflow-hidden rounded-3xl border",
        code.used
          ? "border-transparent bg-white opacity-60 dark:bg-[#1A1A20]"
          : applied
            ? "border-[#BEF04C] bg-[#EDF8C4] dark:border-[#BEF04C]/40 dark:bg-[#1E2410]"
            : "border-transparent bg-white dark:bg-[#1A1A20]"
      )}
    >
      {/* Ticket stub: the big value sits left of the perforation, with punched
          notches eating into the seam top and bottom. */}
      <View className="w-[92px] items-center justify-center border-r-2 border-dashed border-border px-2 py-5">
        <Text className={cn("text-2xl font-extrabold tracking-tight", applied ? "text-[#65A30D]" : "text-[#1B1B26] dark:text-white")}>
          {code.value}
        </Text>
        <View
          className="absolute -right-2 -top-2 h-4 w-4 rounded-full bg-[#F4F5F9] dark:bg-[#111114]"
          accessibilityElementsHidden
          importantForAccessibility="no"
        />
        <View
          className="absolute -bottom-2 -right-2 h-4 w-4 rounded-full bg-[#F4F5F9] dark:bg-[#111114]"
          accessibilityElementsHidden
          importantForAccessibility="no"
        />
      </View>
      <View className="flex-1 gap-1 p-4">
        <View className="flex-row items-center justify-between gap-3">
          <Text variant="small" className="font-bold uppercase tracking-widest">
            {code.code}
          </Text>
          {code.used ? (
            <Badge variant="secondary" size="sm" icon={null}>
              Used
            </Badge>
          ) : applied ? (
            <Badge variant="success" size="sm" icon="check">
              Applied
            </Badge>
          ) : onApply ? (
            <Button
              tone="inverse"
              size="sm"
              className="bg-[#1B1B26]"
              onPress={() => {
                haptics.success();
                onApply(code);
              }}
              accessibilityLabel={`Apply promo code ${code.code}, ${code.title}`}
            >
              Apply
            </Button>
          ) : null}
        </View>
        <Text variant="small" className={code.used ? "text-muted-foreground" : undefined}>
          {code.title}
        </Text>
        {code.detail || code.expiresAt ? (
          <Text variant="muted" className="text-xs">
            {[code.detail, code.expiresAt].filter(Boolean).join(" · ")}
          </Text>
        ) : null}
      </View>
    </View>
  );
}
PromoRow.displayName = "PromoRow";

/** Promo codes — manual entry field, available offers as coupon rows with
 *  per-row Apply, and a grayed "Used & expired" section. */
export function PromoCodesScreen({
  codes = DEFAULT_CODES,
  appliedCode,
  onApply,
  onEnter,
  onBack,
}: PromoCodesScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [draft, setDraft] = useState("");
  // Local mirror of applied codes so Apply buttons flip without a wired host.
  const [applied, setApplied] = useState<Set<string>>(
    () => new Set(appliedCode ? [appliedCode] : [])
  );

  const apply = (c: PromoCode) => {
    setApplied((prev) => new Set(prev).add(c.code));
    onApply?.(c);
  };

  const enter = () => {
    const code = draft.trim().toUpperCase();
    if (!code) return;
    haptics.success();
    setApplied((prev) => new Set(prev).add(code));
    onEnter?.(code);
    setDraft("");
  };

  const available = codes.filter((c) => !c.used);
  const used = codes.filter((c) => c.used);

  return (
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back disc + centered title pill. */}
      <View pointerEvents="box-none" className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }}>
        <View className="flex-row items-center justify-between">
          <Glass interactive effect="regular" className="h-11 w-11 items-center justify-center rounded-full">
            <Press
              haptic="light"
              onPress={() => onBack?.()}
              accessibilityRole="button"
              accessibilityLabel="Go back"
              className="h-9 w-9 items-center justify-center"
            >
              <Icon name="chevron-left" size="md" color="foreground" />
            </Press>
          </Glass>
          <View className="h-11 w-11" />
        </View>
        <View pointerEvents="none" className="absolute inset-0 items-center justify-center">
          <View className="h-11 flex-row items-center justify-center gap-2 rounded-full pl-3.5 pr-5">
            <Glass effect="regular" className="absolute inset-0 rounded-full" />
            <LumioMark size={18} />
            <Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
              Promo codes
            </Text>
          </View>
        </View>
      </View>

      <ScrollView
        className="flex-1"
        showsVerticalScrollIndicator={false}
        contentContainerClassName="gap-3 px-6"
        contentContainerStyle={{ paddingTop: insets.top + 60, paddingBottom: insets.bottom + 24 }}
        keyboardShouldPersistTaps="handled"
      >
        {/* Manual entry — same field + Apply pairing as the cart promo row. */}
        <Mount>
          <View className="flex-row gap-2">
            <View className="flex-1">
              <Input
                placeholder="Enter a code"
                value={draft}
                onChangeText={setDraft}
                autoCapitalize="characters"
                accessibilityLabel="Promo code"
              />
            </View>
            <Button
              tone="inverse"
              className="bg-[#1B1B26]"
              disabled={draft.trim().length === 0}
              onPress={enter}
              accessibilityLabel="Apply entered promo code"
            >
              Apply
            </Button>
          </View>
        </Mount>

        <Mount delay={BLOCK_STAGGER}>
          <Text
            variant="muted"
            className="px-1 pt-2 text-xs font-medium uppercase tracking-wider"
            accessibilityRole="header"
          >
            Available
          </Text>
        </Mount>
        {available.map((c, i) => (
          <Mount key={c.code} delay={Math.min((i + 1) * ROW_STAGGER, ROW_STAGGER_CAP)}>
            <PromoRow code={c} applied={applied.has(c.code)} onApply={apply} />
          </Mount>
        ))}

        {used.length > 0 ? (
          <>
            <Mount delay={BLOCK_STAGGER}>
              <Text
                variant="muted"
                className="px-1 pt-2 text-xs font-medium uppercase tracking-wider"
                accessibilityRole="header"
              >
                Used & expired
              </Text>
            </Mount>
            {used.map((c) => (
              <Mount key={c.code} delay={BLOCK_STAGGER}>
                <PromoRow code={c} applied={false} />
              </Mount>
            ))}
          </>
        ) : null}
        {/* Stacking rule — the promo page's one piece of fine print. */}
        <Text variant="muted" className="px-6 pb-4 pt-6 text-center text-xs">
          One code per order — we always apply the bigger saving
        </Text>
      </ScrollView>
    </SafeAreaView>
  );
}
PromoCodesScreen.displayName = "PromoCodesScreen";
agent prompt — paste into Claude Code, Cursor, Devin…
Recreate the "Promo Codes Screen" screen in React Native using LumioUI.

Goal: Manual code entry plus coupon rows — tracked-out code, offer, terms, and expiry — with per-row Apply and a grayed 'Used & expired' section Match the reference implementation's layout, behavior, and motion exactly — this is a production screen, not a mockup.

## Setup

Fastest path — install the screen plus its component deps:

```bash
npx lumioui add ecommerce-promo-codes
```

Or pull just the components: `npx lumioui add badge button icon input text`

Native packages:
- @lumioui/ui@latest
- @lumioui/core@latest
- react-native-safe-area-context@*
- react-native-reanimated@*
- react-native-svg@*
- nativewind@*

Stack assumptions: Expo SDK 54 / RN 0.81, Reanimated 4, NativeWind v4, TypeScript strict, Expo Go compatible.

## Components — how, where, when

### `badge` — Compact status pill with variants, icons and pulse option.
- `<Badge>` ×2

### `button` — Tactile pill button with press spring, ink wash and async loading.
- `<Button>` ×2

### `icon` — Lucide icon set mapped to theme colors and sizes.
- `<Icon>` ×1

### `input` — Labeled field with focus ring, error shake and success check.
- `<Input>` ×1

### `text` — Themed type scale from caption to display.
- `<Text>` ×8

## Conventions (non-negotiable)

- Styling via NativeWind `className` with semantic tokens only: `bg-background`, `text-foreground`, `bg-card`, `text-card-foreground`, `bg-secondary`, `bg-muted`, `text-muted-foreground`, `bg-accent`, `bg-destructive`, `border-border`. Hard-coded colors only inside media overlays (`text-white`, `bg-black/N`).
- Motion via the token presets from `@lumioui/core` (`spring.press`, `spring.surface`, `spring.glide`, `timing.fast`, `timing.slow`, …) — no bespoke spring configs or durations.
- Gate transform motion behind `useReducedMotion()`; keep opacity/color feedback, drop travel and overshoot.
- Haptics via `useHaptic()`: `light` on press, `selection` on toggle/select, `warning` on invalid input. Never import expo-haptics directly.
- Press feedback via `usePressAnimation()` (~0.97 scale), not `activeOpacity` tricks.
- a11y: `accessibilityRole` + `accessibilityLabel` on every control, touch targets ≥44pt.
- Entrance choreography: staggered `Mount` wrappers (delay 0/60/120…) so regions land in sequence instead of popping in at once.
- Wrap the screen in `SafeAreaView`; keep dark mode working via the semantic tokens.

## Deliverable

One file: `screens/ecommerce/promo-codes.tsx` exporting PromoCodesScreen. Preserve the props interface — the host app wires the callbacks (navigation, submit handlers) through them.

## Reference implementation

The LumioUI source for this screen — reproduce it faithfully:

```tsx
import * as React from "react";
import { useState } from "react";
import { View, ScrollView } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Badge, Button, Glass, Icon, Input, Text } from "@lumioui/ui";
import { cn, useHaptic } from "@lumioui/core";

import { BLOCK_STAGGER, LumioMark, Mount, Press, ROW_STAGGER, ROW_STAGGER_CAP } from "../shared";
export interface PromoCode {
  code: string;
  /** "20% off orders over $150" — the offer in one line. */
  title: string;
  /** Big stub value on the ticket — "20%", "FREE", "$10". */
  value: string;
  /** Terms — "Min. spend $150 · One per order". */
  detail?: string;
  /** "Ends Sep 30" — omitted for evergreen codes. */
  expiresAt?: string;
  /** Already redeemed — renders grayed under "Used & expired". */
  used?: boolean;
}

export interface PromoCodesScreenProps {
  codes?: PromoCode[];
  /** Code applied to the current cart, if the host already has one. */
  appliedCode?: string;
  onApply?: (code: PromoCode) => void;
  /** Manual entry at the top — gets the raw string, not a PromoCode. */
  onEnter?: (code: string) => void;
  onBack?: () => void;
}

const DEFAULT_CODES: PromoCode[] = [
  {
    code: "SAVE20",
    value: "20%",
    title: "off orders over $150",
    detail: "Min. spend $150 · One per order",
    expiresAt: "Ends Sep 30",
  },
  {
    code: "FREESHIP",
    value: "FREE",
    title: "express shipping",
    detail: "Any order · No minimum",
    expiresAt: "Ends Oct 15",
  },
  {
    code: "KNIT15",
    value: "15%",
    title: "off knitwear",
    detail: "Ponchos, sweaters & cardigans",
  },
  {
    code: "WELCOME10",
    value: "$10",
    title: "off your first order",
    detail: "Min. spend $50",
    expiresAt: "Expired Sep 5",
    used: true,
  },
];

function PromoRow({
  code,
  applied,
  onApply,
}: {
  code: PromoCode;
  applied: boolean;
  onApply?: (c: PromoCode) => void;
}) {
  const haptics = useHaptic();
  return (
    <View
      className={cn(
        "flex-row overflow-hidden rounded-3xl border",
        code.used
          ? "border-transparent bg-white opacity-60 dark:bg-[#1A1A20]"
          : applied
            ? "border-[#BEF04C] bg-[#EDF8C4] dark:border-[#BEF04C]/40 dark:bg-[#1E2410]"
            : "border-transparent bg-white dark:bg-[#1A1A20]"
      )}
    >
      {/* Ticket stub: the big value sits left of the perforation, with punched
          notches eating into the seam top and bottom. */}
      <View className="w-[92px] items-center justify-center border-r-2 border-dashed border-border px-2 py-5">
        <Text className={cn("text-2xl font-extrabold tracking-tight", applied ? "text-[#65A30D]" : "text-[#1B1B26] dark:text-white")}>
          {code.value}
        </Text>
        <View
          className="absolute -right-2 -top-2 h-4 w-4 rounded-full bg-[#F4F5F9] dark:bg-[#111114]"
          accessibilityElementsHidden
          importantForAccessibility="no"
        />
        <View
          className="absolute -bottom-2 -right-2 h-4 w-4 rounded-full bg-[#F4F5F9] dark:bg-[#111114]"
          accessibilityElementsHidden
          importantForAccessibility="no"
        />
      </View>
      <View className="flex-1 gap-1 p-4">
        <View className="flex-row items-center justify-between gap-3">
          <Text variant="small" className="font-bold uppercase tracking-widest">
            {code.code}
          </Text>
          {code.used ? (
            <Badge variant="secondary" size="sm" icon={null}>
              Used
            </Badge>
          ) : applied ? (
            <Badge variant="success" size="sm" icon="check">
              Applied
            </Badge>
          ) : onApply ? (
            <Button
              tone="inverse"
              size="sm"
              className="bg-[#1B1B26]"
              onPress={() => {
                haptics.success();
                onApply(code);
              }}
              accessibilityLabel={`Apply promo code ${code.code}, ${code.title}`}
            >
              Apply
            </Button>
          ) : null}
        </View>
        <Text variant="small" className={code.used ? "text-muted-foreground" : undefined}>
          {code.title}
        </Text>
        {code.detail || code.expiresAt ? (
          <Text variant="muted" className="text-xs">
            {[code.detail, code.expiresAt].filter(Boolean).join(" · ")}
          </Text>
        ) : null}
      </View>
    </View>
  );
}
PromoRow.displayName = "PromoRow";

/** Promo codes — manual entry field, available offers as coupon rows with
 *  per-row Apply, and a grayed "Used & expired" section. */
export function PromoCodesScreen({
  codes = DEFAULT_CODES,
  appliedCode,
  onApply,
  onEnter,
  onBack,
}: PromoCodesScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [draft, setDraft] = useState("");
  // Local mirror of applied codes so Apply buttons flip without a wired host.
  const [applied, setApplied] = useState<Set<string>>(
    () => new Set(appliedCode ? [appliedCode] : [])
  );

  const apply = (c: PromoCode) => {
    setApplied((prev) => new Set(prev).add(c.code));
    onApply?.(c);
  };

  const enter = () => {
    const code = draft.trim().toUpperCase();
    if (!code) return;
    haptics.success();
    setApplied((prev) => new Set(prev).add(code));
    onEnter?.(code);
    setDraft("");
  };

  const available = codes.filter((c) => !c.used);
  const used = codes.filter((c) => c.used);

  return (
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back disc + centered title pill. */}
      <View pointerEvents="box-none" className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }}>
        <View className="flex-row items-center justify-between">
          <Glass interactive effect="regular" className="h-11 w-11 items-center justify-center rounded-full">
            <Press
              haptic="light"
              onPress={() => onBack?.()}
              accessibilityRole="button"
              accessibilityLabel="Go back"
              className="h-9 w-9 items-center justify-center"
            >
              <Icon name="chevron-left" size="md" color="foreground" />
            </Press>
          </Glass>
          <View className="h-11 w-11" />
        </View>
        <View pointerEvents="none" className="absolute inset-0 items-center justify-center">
          <View className="h-11 flex-row items-center justify-center gap-2 rounded-full pl-3.5 pr-5">
            <Glass effect="regular" className="absolute inset-0 rounded-full" />
            <LumioMark size={18} />
            <Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
              Promo codes
            </Text>
          </View>
        </View>
      </View>

      <ScrollView
        className="flex-1"
        showsVerticalScrollIndicator={false}
        contentContainerClassName="gap-3 px-6"
        contentContainerStyle={{ paddingTop: insets.top + 60, paddingBottom: insets.bottom + 24 }}
        keyboardShouldPersistTaps="handled"
      >
        {/* Manual entry — same field + Apply pairing as the cart promo row. */}
        <Mount>
          <View className="flex-row gap-2">
            <View className="flex-1">
              <Input
                placeholder="Enter a code"
                value={draft}
                onChangeText={setDraft}
                autoCapitalize="characters"
                accessibilityLabel="Promo code"
              />
            </View>
            <Button
              tone="inverse"
              className="bg-[#1B1B26]"
              disabled={draft.trim().length === 0}
              onPress={enter}
              accessibilityLabel="Apply entered promo code"
            >
              Apply
            </Button>
          </View>
        </Mount>

        <Mount delay={BLOCK_STAGGER}>
          <Text
            variant="muted"
            className="px-1 pt-2 text-xs font-medium uppercase tracking-wider"
            accessibilityRole="header"
          >
            Available
          </Text>
        </Mount>
        {available.map((c, i) => (
          <Mount key={c.code} delay={Math.min((i + 1) * ROW_STAGGER, ROW_STAGGER_CAP)}>
            <PromoRow code={c} applied={applied.has(c.code)} onApply={apply} />
          </Mount>
        ))}

        {used.length > 0 ? (
          <>
            <Mount delay={BLOCK_STAGGER}>
              <Text
                variant="muted"
                className="px-1 pt-2 text-xs font-medium uppercase tracking-wider"
                accessibilityRole="header"
              >
                Used & expired
              </Text>
            </Mount>
            {used.map((c) => (
              <Mount key={c.code} delay={BLOCK_STAGGER}>
                <PromoRow code={c} applied={false} />
              </Mount>
            ))}
          </>
        ) : null}
        {/* Stacking rule — the promo page's one piece of fine print. */}
        <Text variant="muted" className="px-6 pb-4 pt-6 text-center text-xs">
          One code per order — we always apply the bigger saving
        </Text>
      </ScrollView>
    </SafeAreaView>
  );
}
PromoCodesScreen.displayName = "PromoCodesScreen";
```

Screen: https://lumioui.dev/screens/ecommerce-promo-codes
iPhone 17 · iOS
9:41
Live preview — the real screen via Expo Web · open full ↗