v0.1 public beta early access on GitHub
Home / Screens / productivity-note-editor
Screen template

Note Editor Screen

Note editing with formatting strip

pro Expo Go ✓ iosandroid gestures: tap · scroll haptics: light · selection
$ npx lumioui add productivity-note-editor
import { NoteEditorScreen } from "@/screens/productivity/note-editor";
Registry dependencies4
Native packages installed6
@lumioui/ui@latest@lumioui/core@latestreact-native-safe-area-context@*react-native-reanimated@*react-native-svg@*nativewind@*
productivity/note-editor.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, Icon, Text, Textarea } from "@lumioui/ui";
import { Mount, SERIF, World } from "../shared";
import { useHaptic } from "@lumioui/core";

export interface NoteEditorScreenProps {
  initialTitle?: string;
  initialBody?: string;
  updatedAt?: string;
  onSave?: (title: string, body: string) => void;
  onBack?: () => void;
}

/** Note editor — title + body with formatting strip + save. */
export function NoteEditorScreen({
  initialTitle = "Trip ideas — Lisbon",
  initialBody = "Alfama first morning — castle before the crowds.\n\nTram 28 from Martim Moniz, not Baixa (long line).\n\n— Pasteis at Manteigaria, not the tourist one\n— Fado night: Clube de Fado, book ahead\n— Day trip: Sintra if it's clear",
  updatedAt = "Edited today at 9:41 AM",
  onSave,
  onBack,
}: NoteEditorScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [title, setTitle] = React.useState(initialTitle);
  const [body, setBody] = React.useState(initialBody);
  const [touched, setTouched] = React.useState(false);

  const words = React.useMemo(
    () => (body.trim() ? body.trim().split(/\s+/).length : 0),
    [body]
  );

  /** Insert tools append their snippet on a fresh line — real mutation, not
   *  a haptic-only stub. Photo/attach would open pickers in production. */
  const insert = (snippet: string) => {
    haptics.selection();
    setBody((b) => (b === "" || b.endsWith("\n") ? b + snippet : b + "\n" + snippet));
    setTouched(true);
  };

  const tool = (
    icon: Parameters<typeof Icon>[0]["name"],
    label: string,
    onPress?: () => void
  ) => (
    <Button
      key={label}
      variant="ghost"
      size="icon"
      haptic="light"
      onPress={onPress ?? (() => haptics.selection())}
      accessibilityLabel={label}
      className="h-9 w-9"
    >
      <Icon name={icon} size="sm" color="foreground" />
    </Button>
  );

  return (
    <World primary="#65A30D">
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top", "bottom"]}>
      {/* Editor chrome — back + save. */}
      <View className="flex-row items-center justify-between px-4 pb-1 pt-2">
        <Button
          variant="ghost"
          haptic="light"
          onPress={() => {
            haptics.light();
            onSave?.(title, body);
            onBack?.();
          }}
          accessibilityLabel="Done editing"
          className="-ml-2"
        >
          <Text className="font-medium text-[#65A30D]">Done</Text>
        </Button>
        <Text className="text-xs text-muted-foreground">
          {touched ? "Edited just now" : updatedAt}
        </Text>
        <Button
          variant="ghost"
          size="icon"
          haptic="light"
          onPress={() => haptics.light()}
          accessibilityLabel="Note options"
          className="h-8 w-8"
        >
          <Icon name="ellipsis" size="sm" color="mutedForeground" />
        </Button>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingBottom: insets.bottom + 24 }}
      >
        <Textarea
          glass
          value={title}
          onChangeText={setTitle}
          placeholder="Title"
          accessibilityLabel="Note title"
          className="mx-4 min-h-[44px] border-0 bg-transparent text-2xl font-bold"
          style={{ fontFamily: SERIF }}
        />
        <Textarea
          glass
          value={body}
          onChangeText={(v) => {
            setBody(v);
            setTouched(true);
          }}
          placeholder="Start writing..."
          accessibilityLabel="Note body"
          autoGrow
          className="mx-4 min-h-[300px] border-0 bg-transparent text-[15px]"
          style={{ fontFamily: SERIF }}
        />
        <Text className="mx-6 pt-2 text-xs text-muted-foreground">
          {words} {words === 1 ? "word" : "words"}
        </Text>
        {/* Sync receipt — editors close the loop on save. */}
        <Text className="mx-6 text-[10px] text-muted-foreground/70">
          Autosaved · synced just now
        </Text>
      </ScrollView>

      {/* Formatting strip — inserts cluster left, "Aa" format right (iOS
          Notes idiom). */}
      <View className="flex-row items-center justify-between px-4 py-2">
        <Mount className="flex-row items-center gap-3">
          {tool("check-circle", "Insert checklist", () => insert("— [ ] "))}
          {tool("list", "Insert list", () => insert("- "))}
          {tool("image", "Insert photo")}
          {tool("paperclip", "Attach file")}
        </Mount>
        {tool("type", "Text formatting", () => {
          haptics.light();
          insert("**");
        })}
      </View>
    </SafeAreaView>
    </World>
  );
}
NoteEditorScreen.displayName = "NoteEditorScreen";
agent prompt — paste into Claude Code, Cursor, Devin…
Recreate the "Note Editor Screen" screen in React Native using LumioUI.

Goal: Note editing with formatting strip 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 productivity-note-editor
```

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

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>` ×3

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

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

### `textarea` — Multiline field with auto-grow and character count.
- `<Textarea>` ×2

## 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/productivity/note-editor.tsx` exporting NoteEditorScreen. 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, Icon, Text, Textarea } from "@lumioui/ui";
import { Mount, SERIF, World } from "../shared";
import { useHaptic } from "@lumioui/core";

export interface NoteEditorScreenProps {
  initialTitle?: string;
  initialBody?: string;
  updatedAt?: string;
  onSave?: (title: string, body: string) => void;
  onBack?: () => void;
}

/** Note editor — title + body with formatting strip + save. */
export function NoteEditorScreen({
  initialTitle = "Trip ideas — Lisbon",
  initialBody = "Alfama first morning — castle before the crowds.\n\nTram 28 from Martim Moniz, not Baixa (long line).\n\n— Pasteis at Manteigaria, not the tourist one\n— Fado night: Clube de Fado, book ahead\n— Day trip: Sintra if it's clear",
  updatedAt = "Edited today at 9:41 AM",
  onSave,
  onBack,
}: NoteEditorScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [title, setTitle] = React.useState(initialTitle);
  const [body, setBody] = React.useState(initialBody);
  const [touched, setTouched] = React.useState(false);

  const words = React.useMemo(
    () => (body.trim() ? body.trim().split(/\s+/).length : 0),
    [body]
  );

  /** Insert tools append their snippet on a fresh line — real mutation, not
   *  a haptic-only stub. Photo/attach would open pickers in production. */
  const insert = (snippet: string) => {
    haptics.selection();
    setBody((b) => (b === "" || b.endsWith("\n") ? b + snippet : b + "\n" + snippet));
    setTouched(true);
  };

  const tool = (
    icon: Parameters<typeof Icon>[0]["name"],
    label: string,
    onPress?: () => void
  ) => (
    <Button
      key={label}
      variant="ghost"
      size="icon"
      haptic="light"
      onPress={onPress ?? (() => haptics.selection())}
      accessibilityLabel={label}
      className="h-9 w-9"
    >
      <Icon name={icon} size="sm" color="foreground" />
    </Button>
  );

  return (
    <World primary="#65A30D">
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top", "bottom"]}>
      {/* Editor chrome — back + save. */}
      <View className="flex-row items-center justify-between px-4 pb-1 pt-2">
        <Button
          variant="ghost"
          haptic="light"
          onPress={() => {
            haptics.light();
            onSave?.(title, body);
            onBack?.();
          }}
          accessibilityLabel="Done editing"
          className="-ml-2"
        >
          <Text className="font-medium text-[#65A30D]">Done</Text>
        </Button>
        <Text className="text-xs text-muted-foreground">
          {touched ? "Edited just now" : updatedAt}
        </Text>
        <Button
          variant="ghost"
          size="icon"
          haptic="light"
          onPress={() => haptics.light()}
          accessibilityLabel="Note options"
          className="h-8 w-8"
        >
          <Icon name="ellipsis" size="sm" color="mutedForeground" />
        </Button>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingBottom: insets.bottom + 24 }}
      >
        <Textarea
          glass
          value={title}
          onChangeText={setTitle}
          placeholder="Title"
          accessibilityLabel="Note title"
          className="mx-4 min-h-[44px] border-0 bg-transparent text-2xl font-bold"
          style={{ fontFamily: SERIF }}
        />
        <Textarea
          glass
          value={body}
          onChangeText={(v) => {
            setBody(v);
            setTouched(true);
          }}
          placeholder="Start writing..."
          accessibilityLabel="Note body"
          autoGrow
          className="mx-4 min-h-[300px] border-0 bg-transparent text-[15px]"
          style={{ fontFamily: SERIF }}
        />
        <Text className="mx-6 pt-2 text-xs text-muted-foreground">
          {words} {words === 1 ? "word" : "words"}
        </Text>
        {/* Sync receipt — editors close the loop on save. */}
        <Text className="mx-6 text-[10px] text-muted-foreground/70">
          Autosaved · synced just now
        </Text>
      </ScrollView>

      {/* Formatting strip — inserts cluster left, "Aa" format right (iOS
          Notes idiom). */}
      <View className="flex-row items-center justify-between px-4 py-2">
        <Mount className="flex-row items-center gap-3">
          {tool("check-circle", "Insert checklist", () => insert("— [ ] "))}
          {tool("list", "Insert list", () => insert("- "))}
          {tool("image", "Insert photo")}
          {tool("paperclip", "Attach file")}
        </Mount>
        {tool("type", "Text formatting", () => {
          haptics.light();
          insert("**");
        })}
      </View>
    </SafeAreaView>
    </World>
  );
}
NoteEditorScreen.displayName = "NoteEditorScreen";
```

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