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

Filters & sort Screen

Sort radio list, category chips, and price ceiling with apply CTA.

pro Expo Go ✓ iosandroid gestures: tap · scroll haptics: light · selection
$ npx lumioui add ecommerce-filters-sort
import { FiltersSortScreen } from "@/screens/ecommerce/filters-sort";
Registry dependencies6
Native packages installed6
@lumioui/ui@latest@lumioui/core@latestreact-native-safe-area-context@*react-native-reanimated@*react-native-svg@*nativewind@*
ecommerce/filters-sort.tsxsource · yours to edit
import * as React from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Button, Chip, Glass, Icon, List, Slider, Text } from "@lumioui/ui";
import { AnimatedPressable, cn, useHaptic } from "@lumioui/core";
import { LumioMark, Mount, Press, SEPARATOR_INSET, StickyBottomBar, World } from "../shared";

export interface FiltersSortScreenProps {
  sorts?: { key: string; label: string }[];
  categories?: string[];
  onApply?: (state: { sort: string; categories: string[]; maxPrice: number }) => void;
  onBack?: () => void;
}

const DEFAULT_SORTS = [
  { key: "popular", label: "Most popular" },
  { key: "newest", label: "Newest" },
  { key: "price-asc", label: "Price: low to high" },
  { key: "price-desc", label: "Price: high to low" },
  { key: "rating", label: "Top rated" },
];

const DEFAULT_CATEGORIES = [
  "Outerwear",
  "Knitwear",
  "Denim",
  "Footwear",
  "Accessories",
];

const COLORS = [
  { name: "Black", hex: "#1C1917" },
  { name: "Cream", hex: "#F1E4C8" },
  { name: "Camel", hex: "#B7793F" },
  { name: "Navy", hex: "#1E3A5F" },
  { name: "Olive", hex: "#5B6348" },
  { name: "Rust", hex: "#C2410C" },
];

/** Price distribution buckets — the histogram the slider rides under. */
const PRICE_BUCKETS = [18, 42, 88, 64, 51, 36, 22, 14, 9, 5];

/** Filters & sort — sort radio list, category chips, price ceiling, apply. */
export function FiltersSortScreen({
  sorts = DEFAULT_SORTS,
  categories = DEFAULT_CATEGORIES,
  onApply,
  onBack,
}: FiltersSortScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [sort, setSort] = React.useState("popular");
  const [picked, setPicked] = React.useState<string[]>(["Outerwear"]);
  const [size, setSize] = React.useState<string>("M");
  const [color, setColor] = React.useState<string>("Camel");
  const [maxPrice, setMaxPrice] = React.useState(300);
  const activeCount =
    picked.length +
    (sort !== "popular" ? 1 : 0) +
    (size ? 1 : 0) +
    (color ? 1 : 0);

  const toggleCategory = (c: string) => () => {
    haptics.selection();
    setPicked((prev) =>
      prev.includes(c) ? prev.filter((x) => x !== c) : [...prev, c]
    );
  };

  return (
    <World primary="#65A30D">
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back disc + centered title pill + Reset 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 flex-row items-center justify-center rounded-full px-4">
            <Glass effect="regular" className="absolute inset-0 rounded-full" />
            <Press
              haptic="light"
              onPress={() => {
                setSort("popular");
                setPicked([]);
                setSize("");
                setColor("");
                setMaxPrice(300);
              }}
              accessibilityRole="button"
              accessibilityLabel="Reset filters"
              className="items-center justify-center"
            >
              <Text className="text-sm font-semibold">Reset</Text>
            </Press>
          </View>
        </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">
              Filters
            </Text>
            {activeCount > 0 ? (
              <View className="rounded-full bg-[#BEF04C] px-1.5 py-px">
                <Text className="text-[10px] font-bold text-[#1B1B26]">
                  {activeCount}
                </Text>
              </View>
            ) : null}
          </View>
        </View>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingTop: insets.top + 60, paddingBottom: insets.bottom + 120 }}
      >
        <List inset>
          <List.Section title="Sort by">
            {sorts.map((s, ii) => (
              <React.Fragment key={s.key}>
                {ii > 0 && <List.Separator className={SEPARATOR_INSET} />}
                <List.Item
                  title={s.label}
                  haptic="selection"
                  onPress={() => setSort(s.key)}
                  accessibilityRole="radio"
                  accessibilityState={{ selected: sort === s.key }}
                  trailing={
                    sort === s.key ? (
                      <View className="h-6 w-6 items-center justify-center rounded-full bg-[#BEF04C]">
                        <Icon name="check" size="sm" color="#1B1B26" />
                      </View>
                    ) : undefined
                  }
                />
              </React.Fragment>
            ))}
          </List.Section>
        </List>

        <Mount delay={60} className="mx-4 mt-5 gap-3 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <Text variant="small" className="text-muted-foreground">
            Category
          </Text>
          <View className="flex-row flex-wrap gap-2">
            {categories.map((c) => (
              <Chip
                key={c}
                variant={picked.includes(c) ? "assist" : "filter"}
                selected={picked.includes(c)}
                onPress={toggleCategory(c)}
                accessibilityState={{ selected: picked.includes(c) }}
              >
                {c}
              </Chip>
            ))}
          </View>
        </Mount>

        {/* Size tiles — fashion filters always carry size. */}
        <Mount delay={90} className="mx-4 mt-4 gap-3 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <Text variant="small" className="text-muted-foreground">
            Size
          </Text>
          <View className="flex-row gap-2">
            {["XS", "S", "M", "L", "XL"].map((s) => {
              const on = size === s;
              return (
                <AnimatedPressable
                  key={s}
                  onPress={() => {
                    haptics.selection();
                    setSize(s);
                  }}
                  accessibilityRole="button"
                  accessibilityState={{ selected: on }}
                  className={cn(
                    "h-11 flex-1 items-center justify-center rounded-xl border",
                    on ? "border-transparent bg-[#1B1B26]" : "border-border bg-transparent",
                  )}
                >
                  <Text
                    className={cn(
                      "text-sm font-semibold",
                      on ? "text-white" : "text-foreground",
                    )}
                  >
                    {s}
                  </Text>
                </AnimatedPressable>
              );
            })}
          </View>
        </Mount>

        {/* Color swatches — round dots, ring on the picked one. */}
        <Mount delay={110} className="mx-4 mt-4 gap-3 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <Text variant="small" className="text-muted-foreground">
            Colour
          </Text>
          <View className="flex-row gap-3">
            {COLORS.map((c) => {
              const on = color === c.name;
              return (
                <AnimatedPressable
                  key={c.name}
                  onPress={() => {
                    haptics.selection();
                    setColor(c.name);
                  }}
                  accessibilityRole="button"
                  accessibilityLabel={`Colour ${c.name}`}
                  accessibilityState={{ selected: on }}
                  className="items-center gap-1"
                >
                  <View
                    className={cn(
                      "h-9 w-9 items-center justify-center rounded-full",
                      on && "border-2 border-[#65A30D]",
                    )}
                  >
                    <View
                      className="h-7 w-7 rounded-full border border-border"
                      style={{ backgroundColor: c.hex }}
                    />
                  </View>
                  {on && (
                    <View className="h-1 w-1 rounded-full bg-[#65A30D]" />
                  )}
                </AnimatedPressable>
              );
            })}
          </View>
        </Mount>

        <Mount delay={120} className="mx-4 mt-4 gap-2 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <View className="flex-row items-baseline justify-between">
            <Text variant="small" className="text-muted-foreground">
              Max price
            </Text>
            <Text variant="small" className="font-medium">
              Up to ${maxPrice}
            </Text>
          </View>
          {/* Price histogram — where the inventory actually sits. */}
          <View className="flex-row items-end justify-between px-0.5 pt-1">
            {PRICE_BUCKETS.map((v, i) => {
              const bucketCap = 20 + (i + 1) * 58;
              const inRange = bucketCap <= maxPrice;
              return (
                <View
                  key={i}
                  className={`w-[7px] rounded-sm ${inRange ? "bg-[#BEF04C]" : "bg-muted"}`}
                  style={{ height: 4 + (v / 88) * 26 }}
                  accessibilityElementsHidden
                  importantForAccessibility="no"
                />
              );
            })}
          </View>
          <Slider
            value={maxPrice}
            onValueChange={setMaxPrice}
            min={20}
            max={600}
            step={10}
            accessibilityLabel="Maximum price"
          />
          <View className="flex-row justify-between">
            <Text className="text-[10px] text-muted-foreground">$20</Text>
            <Text className="text-[10px] text-muted-foreground">$600</Text>
          </View>
        </Mount>
      </ScrollView>

      <StickyBottomBar>
        <Button
          tone="inverse" className="w-full bg-[#1B1B26]"
          haptic="medium"
          onPress={() => {
            haptics.medium();
            onApply?.({ sort, categories: picked, maxPrice });
          }}
          accessibilityLabel="Apply filters"
        >
          {`Show ${picked.length > 0 ? picked.length * 24 : 240} results`}
        </Button>
      </StickyBottomBar>
    </SafeAreaView>
    </World>
  );
}
FiltersSortScreen.displayName = "FiltersSortScreen";
agent prompt — paste into Claude Code, Cursor, Devin…
Recreate the "Filters & sort Screen" screen in React Native using LumioUI.

Goal: Sort radio list, category chips, and price ceiling with apply CTA. 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-filters-sort
```

Or pull just the components: `npx lumioui add button chip icon list slider 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

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

### `chip` — Compact selectable pill with press scale and ink overlay.
- `<Chip>` ×1

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

### `list` — Settings-style rows with separators and press feedback.
- `<List>` ×1

### `slider` — Draggable track with haptic ticks and precise thumb.
- `<Slider>` ×1

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

## 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/filters-sort.tsx` exporting FiltersSortScreen. 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 { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Button, Chip, Glass, Icon, List, Slider, Text } from "@lumioui/ui";
import { AnimatedPressable, cn, useHaptic } from "@lumioui/core";
import { LumioMark, Mount, Press, SEPARATOR_INSET, StickyBottomBar, World } from "../shared";

export interface FiltersSortScreenProps {
  sorts?: { key: string; label: string }[];
  categories?: string[];
  onApply?: (state: { sort: string; categories: string[]; maxPrice: number }) => void;
  onBack?: () => void;
}

const DEFAULT_SORTS = [
  { key: "popular", label: "Most popular" },
  { key: "newest", label: "Newest" },
  { key: "price-asc", label: "Price: low to high" },
  { key: "price-desc", label: "Price: high to low" },
  { key: "rating", label: "Top rated" },
];

const DEFAULT_CATEGORIES = [
  "Outerwear",
  "Knitwear",
  "Denim",
  "Footwear",
  "Accessories",
];

const COLORS = [
  { name: "Black", hex: "#1C1917" },
  { name: "Cream", hex: "#F1E4C8" },
  { name: "Camel", hex: "#B7793F" },
  { name: "Navy", hex: "#1E3A5F" },
  { name: "Olive", hex: "#5B6348" },
  { name: "Rust", hex: "#C2410C" },
];

/** Price distribution buckets — the histogram the slider rides under. */
const PRICE_BUCKETS = [18, 42, 88, 64, 51, 36, 22, 14, 9, 5];

/** Filters & sort — sort radio list, category chips, price ceiling, apply. */
export function FiltersSortScreen({
  sorts = DEFAULT_SORTS,
  categories = DEFAULT_CATEGORIES,
  onApply,
  onBack,
}: FiltersSortScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [sort, setSort] = React.useState("popular");
  const [picked, setPicked] = React.useState<string[]>(["Outerwear"]);
  const [size, setSize] = React.useState<string>("M");
  const [color, setColor] = React.useState<string>("Camel");
  const [maxPrice, setMaxPrice] = React.useState(300);
  const activeCount =
    picked.length +
    (sort !== "popular" ? 1 : 0) +
    (size ? 1 : 0) +
    (color ? 1 : 0);

  const toggleCategory = (c: string) => () => {
    haptics.selection();
    setPicked((prev) =>
      prev.includes(c) ? prev.filter((x) => x !== c) : [...prev, c]
    );
  };

  return (
    <World primary="#65A30D">
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back disc + centered title pill + Reset 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 flex-row items-center justify-center rounded-full px-4">
            <Glass effect="regular" className="absolute inset-0 rounded-full" />
            <Press
              haptic="light"
              onPress={() => {
                setSort("popular");
                setPicked([]);
                setSize("");
                setColor("");
                setMaxPrice(300);
              }}
              accessibilityRole="button"
              accessibilityLabel="Reset filters"
              className="items-center justify-center"
            >
              <Text className="text-sm font-semibold">Reset</Text>
            </Press>
          </View>
        </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">
              Filters
            </Text>
            {activeCount > 0 ? (
              <View className="rounded-full bg-[#BEF04C] px-1.5 py-px">
                <Text className="text-[10px] font-bold text-[#1B1B26]">
                  {activeCount}
                </Text>
              </View>
            ) : null}
          </View>
        </View>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingTop: insets.top + 60, paddingBottom: insets.bottom + 120 }}
      >
        <List inset>
          <List.Section title="Sort by">
            {sorts.map((s, ii) => (
              <React.Fragment key={s.key}>
                {ii > 0 && <List.Separator className={SEPARATOR_INSET} />}
                <List.Item
                  title={s.label}
                  haptic="selection"
                  onPress={() => setSort(s.key)}
                  accessibilityRole="radio"
                  accessibilityState={{ selected: sort === s.key }}
                  trailing={
                    sort === s.key ? (
                      <View className="h-6 w-6 items-center justify-center rounded-full bg-[#BEF04C]">
                        <Icon name="check" size="sm" color="#1B1B26" />
                      </View>
                    ) : undefined
                  }
                />
              </React.Fragment>
            ))}
          </List.Section>
        </List>

        <Mount delay={60} className="mx-4 mt-5 gap-3 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <Text variant="small" className="text-muted-foreground">
            Category
          </Text>
          <View className="flex-row flex-wrap gap-2">
            {categories.map((c) => (
              <Chip
                key={c}
                variant={picked.includes(c) ? "assist" : "filter"}
                selected={picked.includes(c)}
                onPress={toggleCategory(c)}
                accessibilityState={{ selected: picked.includes(c) }}
              >
                {c}
              </Chip>
            ))}
          </View>
        </Mount>

        {/* Size tiles — fashion filters always carry size. */}
        <Mount delay={90} className="mx-4 mt-4 gap-3 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <Text variant="small" className="text-muted-foreground">
            Size
          </Text>
          <View className="flex-row gap-2">
            {["XS", "S", "M", "L", "XL"].map((s) => {
              const on = size === s;
              return (
                <AnimatedPressable
                  key={s}
                  onPress={() => {
                    haptics.selection();
                    setSize(s);
                  }}
                  accessibilityRole="button"
                  accessibilityState={{ selected: on }}
                  className={cn(
                    "h-11 flex-1 items-center justify-center rounded-xl border",
                    on ? "border-transparent bg-[#1B1B26]" : "border-border bg-transparent",
                  )}
                >
                  <Text
                    className={cn(
                      "text-sm font-semibold",
                      on ? "text-white" : "text-foreground",
                    )}
                  >
                    {s}
                  </Text>
                </AnimatedPressable>
              );
            })}
          </View>
        </Mount>

        {/* Color swatches — round dots, ring on the picked one. */}
        <Mount delay={110} className="mx-4 mt-4 gap-3 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <Text variant="small" className="text-muted-foreground">
            Colour
          </Text>
          <View className="flex-row gap-3">
            {COLORS.map((c) => {
              const on = color === c.name;
              return (
                <AnimatedPressable
                  key={c.name}
                  onPress={() => {
                    haptics.selection();
                    setColor(c.name);
                  }}
                  accessibilityRole="button"
                  accessibilityLabel={`Colour ${c.name}`}
                  accessibilityState={{ selected: on }}
                  className="items-center gap-1"
                >
                  <View
                    className={cn(
                      "h-9 w-9 items-center justify-center rounded-full",
                      on && "border-2 border-[#65A30D]",
                    )}
                  >
                    <View
                      className="h-7 w-7 rounded-full border border-border"
                      style={{ backgroundColor: c.hex }}
                    />
                  </View>
                  {on && (
                    <View className="h-1 w-1 rounded-full bg-[#65A30D]" />
                  )}
                </AnimatedPressable>
              );
            })}
          </View>
        </Mount>

        <Mount delay={120} className="mx-4 mt-4 gap-2 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <View className="flex-row items-baseline justify-between">
            <Text variant="small" className="text-muted-foreground">
              Max price
            </Text>
            <Text variant="small" className="font-medium">
              Up to ${maxPrice}
            </Text>
          </View>
          {/* Price histogram — where the inventory actually sits. */}
          <View className="flex-row items-end justify-between px-0.5 pt-1">
            {PRICE_BUCKETS.map((v, i) => {
              const bucketCap = 20 + (i + 1) * 58;
              const inRange = bucketCap <= maxPrice;
              return (
                <View
                  key={i}
                  className={`w-[7px] rounded-sm ${inRange ? "bg-[#BEF04C]" : "bg-muted"}`}
                  style={{ height: 4 + (v / 88) * 26 }}
                  accessibilityElementsHidden
                  importantForAccessibility="no"
                />
              );
            })}
          </View>
          <Slider
            value={maxPrice}
            onValueChange={setMaxPrice}
            min={20}
            max={600}
            step={10}
            accessibilityLabel="Maximum price"
          />
          <View className="flex-row justify-between">
            <Text className="text-[10px] text-muted-foreground">$20</Text>
            <Text className="text-[10px] text-muted-foreground">$600</Text>
          </View>
        </Mount>
      </ScrollView>

      <StickyBottomBar>
        <Button
          tone="inverse" className="w-full bg-[#1B1B26]"
          haptic="medium"
          onPress={() => {
            haptics.medium();
            onApply?.({ sort, categories: picked, maxPrice });
          }}
          accessibilityLabel="Apply filters"
        >
          {`Show ${picked.length > 0 ? picked.length * 24 : 240} results`}
        </Button>
      </StickyBottomBar>
    </SafeAreaView>
    </World>
  );
}
FiltersSortScreen.displayName = "FiltersSortScreen";
```

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