---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Settings

A column of sections over the whole window, the open section's rows beside it, a round close

This recipe draws SettingsPage `arrangement="mode"`, the one arrangement Meadow draws: the settings cover the app, as the frame does, so the page is drawn in the frame's place, never inside `ScreenFrame`.

Copy the file below whole (`src/screens/settings.tsx`) beside `frame.tsx` (`docs/screen-frame.md`) and swap the sections and rows for your settings; keep the parts and their props. SettingsPage: the grey section column at the window's start (its top bar, then the Sidebar `variant="settings"` of 32 px rows in labelled groups, the open one washed), the open section beside it (its heading and line, then its rows, 40 px apart), the round close at the window's top end. The close and Escape go back where the settings were opened from (the app's start when the visit began here). Each row is a Field, its control at its end (under its words on a phone): a name a TextInput, a choice a Select, an on/off a Switch that takes effect at once, a request a Button whose toast says it is on its way. The light and dark choice is the theme's own (`useColorMode`): the rail's switch and this row keep the same choice. Below 768 px the section column folds into a sheet opened from the bar. Keep the values where your app keeps the person's settings (your API's first answer); here they live while the settings are open. Light, dark, phone and desktop are the parts' own: add no class for them.

```tsx
// src/screens/settings.tsx: the settings, over the whole window, a section open beside the column of sections
import { useState } from 'react';
import { SettingsPage } from '@/components/goop/patterns/settings-page';
import { Button } from '@/components/ui/goop/button';
import { useColorMode } from '@/components/ui/goop/color-mode-toggle';
import { Field } from '@/components/ui/goop/field';
import {
  PageHeader,
  PageHeaderContent,
  PageHeaderDescription,
  PageHeaderTitle,
} from '@/components/ui/goop/page-header';
import {
  Select,
  SelectContent,
  SelectIcon,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from '@/components/ui/goop/select';
import { Sidebar, SidebarContent } from '@/components/ui/goop/sidebar';
import {
  SidebarGroup,
  SidebarGroupContent,
  SidebarGroupLabel,
  SidebarMenu,
  SidebarMenuItem,
} from '@/components/ui/goop/sidebar-group';
import { SidebarMenuButton } from '@/components/ui/goop/sidebar-menu-button';
import { Switch } from '@/components/ui/goop/switch';
import { TextInput } from '@/components/ui/goop/text-input';
import { toast } from '@/components/ui/goop/toast';
import { TopBar, TopBarGroup, TopBarRow, TopBarTitle } from '@/components/ui/goop/top-bar';
import type { IconName } from '@/lib/goop/meadow/glyph';
import { go } from './router';

// ---- the sections: swap them for yours
type Section = { id: string; words: string; icon: IconName; line: string };
const GROUPS: readonly { label: string; sections: readonly Section[] }[] = [
  {
    label: 'Workspace',
    sections: [
      { id: 'general', words: 'General', icon: 'tabler-outline:settings', line: 'The workspace your crew plans in.' },
    ],
  },
  {
    label: 'Your account',
    sections: [
      {
        id: 'profile',
        words: 'Profile',
        icon: 'tabler-outline:user-circle',
        line: 'How your crew sees you on notes and plans.',
      },
      { id: 'notifications', words: 'Notifications', icon: 'tabler-outline:bell', line: 'What reaches you, and when.' },
    ],
  },
  {
    label: 'App',
    sections: [
      { id: 'appearance', words: 'Appearance', icon: 'tabler-outline:sun', line: 'How the app looks on this device.' },
    ],
  },
];
const SECTIONS = GROUPS.flatMap((group) => group.sections);
const WEEK_STARTS = [
  { value: 'monday', words: 'Monday' },
  { value: 'sunday', words: 'Sunday' },
];
const MODES = [
  { value: 'system', words: 'As the device is set' },
  { value: 'light', words: 'Light' },
  { value: 'dark', words: 'Dark' },
] as const;

/** Leaves the settings: back to the page they were opened from, or the app's start when the visit began here. */
const leave = () => (window.history.length > 1 ? window.history.back() : go('/'));

export default function SettingsScreen() {
  const [open, setOpen] = useState('general');
  const [workspace, setWorkspace] = useState('Fieldwork');
  const [weekStarts, setWeekStarts] = useState('monday');
  const [name, setName] = useState('Teodora Valk');
  const [exported, setExported] = useState(false);
  const [digest, setDigest] = useState(true);
  const [reminders, setReminders] = useState(false);
  const { choice, setChoice } = useColorMode();
  const section = SECTIONS.find((one) => one.id === open) ?? (SECTIONS[0] as Section);
  return (
    <SettingsPage
      arrangement="mode"
      onClose={leave}
      header={
        <TopBar>
          <TopBarRow>
            <TopBarGroup align="start">
              <TopBarTitle>Settings</TopBarTitle>
            </TopBarGroup>
          </TopBarRow>
        </TopBar>
      }
      subNav={
        <Sidebar variant="settings" aria-label="Settings" shortcut={false}>
          <SidebarContent>
            {GROUPS.map((group) => (
              <SidebarGroup key={group.label}>
                <SidebarGroupLabel>{group.label}</SidebarGroupLabel>
                <SidebarGroupContent>
                  <SidebarMenu>
                    {group.sections.map((one) => (
                      <SidebarMenuItem key={one.id}>
                        <SidebarMenuButton
                          size="lg"
                          icon={one.icon}
                          isActive={one.id === section.id}
                          onClick={() => setOpen(one.id)}
                        >
                          {one.words}
                        </SidebarMenuButton>
                      </SidebarMenuItem>
                    ))}
                  </SidebarMenu>
                </SidebarGroupContent>
              </SidebarGroup>
            ))}
          </SidebarContent>
        </Sidebar>
      }
      heading={
        <PageHeader>
          <PageHeaderContent>
            <PageHeaderTitle asChild>
              <h1>{section.words}</h1>
            </PageHeaderTitle>
            <PageHeaderDescription>{section.line}</PageHeaderDescription>
          </PageHeaderContent>
        </PageHeader>
      }
      sections={
        section.id === 'general' ? (
          <ul>
            <Field as="li" label="Workspace name" description="On every note and invitation.">
              <TextInput value={workspace} onChange={(event) => setWorkspace(event.currentTarget.value)} />
            </Field>
            <Field as="li" label="Week starts on" description="In the calendar and the week's to-dos.">
              {(control) => (
                <Select value={weekStarts} onValueChange={setWeekStarts}>
                  <SelectTrigger {...control}>
                    <SelectValue />
                    <SelectIcon />
                  </SelectTrigger>
                  <SelectContent searchLabel="Week starts on" search={false}>
                    {WEEK_STARTS.map((day) => (
                      <SelectItem key={day.value} value={day.value}>
                        {day.words}
                      </SelectItem>
                    ))}
                  </SelectContent>
                </Select>
              )}
            </Field>
          </ul>
        ) : section.id === 'profile' ? (
          <>
            <ul>
              <Field as="li" label="Name" description="Shown on notes, plans and invitations.">
                <TextInput value={name} onChange={(event) => setName(event.currentTarget.value)} />
              </Field>
            </ul>
            <ul>
              <Field as="li" label="Export your notes" description="A copy of your notes, sent to your email.">
                <Button
                  variant="outline"
                  disabled={exported}
                  onClick={() => {
                    setExported(true);
                    toast('Your export is on its way');
                  }}
                >
                  {exported ? 'Export on its way' : 'Export notes'}
                </Button>
              </Field>
            </ul>
          </>
        ) : section.id === 'notifications' ? (
          <ul>
            <Field as="li" label="Weekly digest" description="A summary of the week’s notes every Monday.">
              {(control) => <Switch {...control} checked={digest} onCheckedChange={setDigest} />}
            </Field>
            <Field as="li" label="Planting-day reminders" description="A note the evening before each planting day.">
              {(control) => <Switch {...control} checked={reminders} onCheckedChange={setReminders} />}
            </Field>
          </ul>
        ) : (
          <ul>
            <Field as="li" label="Theme" description="Light, dark, or as the device is set.">
              {(control) => (
                <Select value={choice} onValueChange={(next) => setChoice(next as typeof choice)}>
                  <SelectTrigger {...control}>
                    <SelectValue />
                    <SelectIcon />
                  </SelectTrigger>
                  <SelectContent searchLabel="Theme" search={false}>
                    {MODES.map((mode) => (
                      <SelectItem key={mode.value} value={mode.value}>
                        {mode.words}
                      </SelectItem>
                    ))}
                  </SelectContent>
                </Select>
              )}
            </Field>
          </ul>
        )
      }
    />
  );
}
```
