aiellie

Search

Find a component, template or page

GitHub
Design

Settings Dialog

A settings window with a section rail on the left and, on the right, a Settings › Section breadcrumb over the active account, appearance, model provider keys, or API keys section. On small screens the rail folds into the breadcrumb.

fig. 01 · open it full screen from the corner

Installation

npx shadcn@latest add "@aiellie/settings-dialog"

shadcn needs the @aiellie registry in components.json first. npx aiellie add settings-dialog adds it on its first run, then installs the same way.

Settings dialog is an app's settings in one window: a rail of sections on the left, the chosen section on the right, and a single Save for all of it. It covers the person's name and email, the theme, keys for the model providers they bring, and API keys they make. Nothing is saved until Save, so Cancel throws every change away.

Getting started

  1. Open it with the current settings

    It is controlled by open. Everything else is what it starts from each time it opens.

    components/settings-button.tsx
    "use client"
    
    import * as React from "react"
    
    import { SettingsDialog } from "@/components/ui/settings-dialog"
    import { Button } from "@/components/ui/button"
    
    export function SettingsButton({ user }: { user: { name: string; email: string } }) {
      const [open, setOpen] = React.useState(false)
    
      return (
        <>
          <Button variant="outline" onClick={() => setOpen(true)}>
            Settings
          </Button>
          <SettingsDialog
            open={open}
            onOpenChange={setOpen}
            user={user}
            theme="system"
            onSave={(values) => saveSettings(values)}
          />
        </>
      )
    }
  2. Let people bring their own keys

    Pass providers to add the Providers section. PROVIDERS from @/lib/models lists the gateway, OpenAI, Anthropic and Google, the ones the chat block's route reads. A provider without a key is left out of providerKeys.

    import { PROVIDERS } from "@/lib/models"
    
    <SettingsDialog
      providers={PROVIDERS}
      providerKeys={keys}
      onSave={(values) => setKeys(values.providerKeys)}
      {...props}
    />

Anatomy

<div data-slot="dialog-content"> {/* 768px wide at most, 480px tall */}
  <form>
    <div data-slot="sidebar-wrapper">
      <div data-slot="sidebar"> {/* General, Appearance, Providers, API keys; hidden below md */}
        <button data-slot="sidebar-menu-button" data-active />
      </div>
      <div>
        <nav data-slot="breadcrumb" /> {/* Settings › Section; below md, a menu of sections */}
        <section /> {/* the chosen section; only this scrolls */}
        <footer>
          <button /> {/* Cancel */}
          <button type="submit" /> {/* Save changes */}
        </footer>
      </div>
    </div>
  </form>
</div>

The rail is a sidebar rather than tabs, a 30px row per section with the current one filled, and the breadcrumb names the section again over the pane. The header and footer stay put and only the section scrolls. Below md the rail is hidden and the breadcrumb becomes a menu of the sections, so a phone still reaches all of them.

Provider keys are hidden in their fields, with a button to show one. A new API key is shown whole once, right after it is made, with a copy button; after that only its first three and last four characters are. The Providers section is left out without providers.

Examples

Open on a section

defaultSection picks the section it opens on, here Providers for a button that asks for a key.

No keys saved

API keys

Pass the keys someone has made. Ones they make or revoke come back in onSave.

<SettingsDialog
  apiKeys={[
    { id: "key_1", name: "Production", secret: "sk-live-7f2a9c1e4b80", createdAt: "2026-03-12" },
  ]}
  defaultSection="api-keys"
  {...props}
/>

API reference

SettingsDialog

PropTypeDefaultDescription
openbooleanrequiredWhether the dialog is open.
onOpenChange(open: boolean) => voidrequiredCalled to open or close it. Cancel and Save both close it.
userSettingsUserrequiredWho they are, filling the General section.
theme"system" | "light" | "dark""system"The theme chosen.
apiKeysSettingsApiKey[][]The API keys they have made.
providersSettingsProvider[][]Providers they bring a key for. Without any, the section is left out.
providerKeysRecord<string, string>{}Their keys, keyed by provider id.
defaultSection"general" | "appearance" | "providers" | "api-keys""general"The section shown each time it opens.
onSave(values: SettingsValues) => voidCalled with every value when Save is pressed.

SettingsValues

FieldTypeDescription
name / emailstringFrom General.
themeSettingsThemeFrom Appearance.
apiKeysSettingsApiKey[]Every key, including ones just made.
providerKeysRecord<string, string>Keyed by provider id. A provider without a key is left out.

SettingsProvider and SettingsApiKey

FieldTypeDescription
SettingsProvider.id / namestringThe provider.
SettingsProvider.descriptionstringWhich models its key reaches, in a few words.
SettingsProvider.keysUrlstringWhere a key for it is made, linked beside its field.
SettingsProvider.placeholderstringHow its keys begin, shown in an empty field.
SettingsApiKey.id / name / secretstringThe key. secret is shown in full only right after it is made.
SettingsApiKey.createdAtstringA calendar date, YYYY-MM-DD.