BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/tool-ui/preferences-panel

Preferences Panel

tool-ui/preferences-panel
FreeBlock

Compact settings panel for user preferences.

See it running

Open the demo on tool-ui

www.tool-ui.com/components/preferences-panel
Open
This registry sends X-Frame-Options, so its page cannot be embedded here. The link is the same page the frame would have shown.

Install it

npx shadcn@latest add https://www.tool-ui.com/r/preferences-panel.json

Source

components/tool-ui/preferences-panel/preferences-panel.tsxwww.tool-ui.com/r/preferences-panel.json · first 6 KB
1"use client";
2
3import { useCallback, useMemo } from "react";
4import type {
5 PreferencesPanelProps,
6 PreferencesPanelReceiptProps,
7 PreferencesValue,
8 PreferenceItem,
9 PreferenceSection,
10} from "./schema";
11import { ActionButtons } from "../shared/action-buttons";
12import { normalizeActionsConfig } from "../shared/actions-config";
13import { type Action } from "../shared/schema";
14import { useControllableState } from "../shared/use-controllable-state";
15import { useSignatureReset } from "../shared/use-signature-reset";
16
17import {
18 cn,
19 Switch,
20 ToggleGroup,
21 ToggleGroupItem,
22 Select,
23 SelectContent,
24 SelectItem,
25 SelectTrigger,
26 SelectValue,
27 Separator,
28 Label,
29} from "./_adapter";
30import { Check, AlertCircle } from "lucide-react";
31import { createPreferencesSectionSignature } from "./signature";
32
33function getInitialValue(item: PreferenceItem): string | boolean {
34 switch (item.type) {
35 case "switch":
36 return item.defaultChecked ?? false;
37 case "toggle":
38 return item.defaultValue ?? item.options?.[0]?.value ?? "";
39 case "select":
40 return item.defaultSelected ?? item.selectOptions?.[0]?.value ?? "";
41 }
42}
43
44function formatDisplayValue(
45 item: PreferenceItem,
46 value: string | boolean,
47): string {
48 if (item.type === "switch") {
49 return typeof value === "boolean" && value ? "On" : "Off";
50 }
51
52 const stringValue = typeof value === "string" ? value : "";
53 const options = item.type === "toggle" ? item.options : item.selectOptions;
54 const option = options?.find((opt) => opt.value === stringValue);
55
56 return option?.label ?? stringValue;
57}
58
59function computeInitialValues(sections: PreferenceSection[]): PreferencesValue {
60 return sections.reduce<PreferencesValue>((acc, section) => {
61 section.items.forEach((item) => {
62 acc[item.id] = getInitialValue(item);
63 });
64 return acc;
65 }, {});
66}
67
68interface PreferenceControlProps {
69 item: PreferenceItem;
70 value: string | boolean;
71 onChange: (value: string | boolean) => void;
72 disabled?: boolean;
73}
74
75function SwitchControl({
76 id,
77 checked,
78 onChange,
79 disabled,
80 label,
81}: {
82 id: string;
83 checked: boolean;
84 onChange: (value: boolean) => void;
85 disabled?: boolean;
86 label: string;
87}) {
88 return (
89 <Switch
90 id={id}
91 checked={checked}
92 onCheckedChange={onChange}
93 disabled={disabled}
94 aria-label={label}
95 />
96 );
97}
98
99function ToggleControl({
100 value,
101 options,
102 onChange,
103 disabled,
104 label,
105}: {
106 value: string;
107// … truncated

What it pulls in

npm packages

  • lucide-react
  • zod

Other registry items

  • button
  • label
  • select
  • separator
  • switch
  • toggle-group

Files it writes

  • components/tool-ui/preferences-panel/_adapter.tsx
  • components/tool-ui/preferences-panel/index.tsx
  • components/tool-ui/preferences-panel/preferences-panel.tsx
  • components/tool-ui/preferences-panel/README.md
  • components/tool-ui/preferences-panel/schema.ts
  • components/tool-ui/preferences-panel/signature.ts
  • components/tool-ui/shared/_adapter.tsx
  • components/tool-ui/shared/action-buttons.tsx
  • components/tool-ui/shared/actions-config.ts
  • components/tool-ui/shared/contract.ts
  • components/tool-ui/shared/embedded-actions.ts
  • components/tool-ui/shared/parse.ts
  • components/tool-ui/shared/schema.ts
  • components/tool-ui/shared/use-action-buttons.tsx
  • components/tool-ui/shared/use-controllable-state.ts
  • components/tool-ui/shared/use-signature-reset.ts

Facts

Registry
tool-ui
Type
registry:block
Access
Free
Files written
16
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
today

Go to the source

Docs on tool-ui www.tool-ui.com Raw registry item This item as JSON

More from tool-ui

All 27 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Approval Cardapproval-cardtool-uiBlocksFree2 deps · 11 files
Audioaudiotool-uiBlocksFree2 deps · 9 files
Chartcharttool-uiBlocksFree2 deps · 8 files
Citationcitationtool-uiBlocksFree2 deps · 15 files
Code Blockcode-blocktool-uiBlocksFree3 deps · 11 files
Code Diffcode-difftool-uiBlocksFree3 deps · 10 files
Data Tabledata-tabletool-uiBlocksFree1 dep · 17 files
Geo Mapgeo-maptool-uiBlocksFree4 deps · 12 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex