BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shuip/rhf-inline-edit

rhf-inline-edit

shuip/rhf-inline-edit
FreeComponent

shuip publishes no description for this item.

Live preview

live · rendered by the registry
Rendered by shuip on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://shuip.plvo.dev/r/rhf-inline-edit.json

Source

./items/react-hook-form/inline-edit/component.tsxshuip.plvo.dev/r/rhf-inline-edit.json · first 6 KB
1'use client';
2
3import type { Lens } from '@hookform/lenses';
4import { InfoIcon } from 'lucide-react';
5import * as React from 'react';
6import { useController, useFormContext } from 'react-hook-form';
7import { Field, FieldLabel } from '@/components/ui/field';
8import { Input } from '@/components/ui/input';
9import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
10import { Textarea } from '@/components/ui/textarea';
11import { cn } from '@/lib/utils';
12
13type InlineEditSize = 'sm' | 'default' | 'title';
14type InlineEditVariant = 'ghost' | 'boxed';
15type InlineEditInput = 'text' | 'textarea';
16
17interface InlineEditProps {
18 value: string;
19 onCommit: (next: string) => Promise<string | undefined> | string | undefined;
20 input?: InlineEditInput;
21 variant?: InlineEditVariant;
22 size?: InlineEditSize;
23 placeholder?: string;
24 canEdit?: boolean;
25 children?: (api: {
26 value: string;
27 setValue: (v: string) => void;
28 commit: (next?: string) => void;
29 cancel: () => void;
30 className: string;
31 autoFocus: true;
32 }) => React.ReactNode;
33}
34
35type State =
36 | { kind: 'reading' }
37 | { kind: 'editing'; draft: string; error?: string }
38 | { kind: 'saving'; draft: string };
39
40const sizeClasses: Record<InlineEditSize, string> = {
41 sm: 'px-1.5 py-0.5 text-xs',
42 default: 'px-2 py-1 text-sm',
43 title: 'px-2 py-1 text-3xl font-semibold tracking-tight',
44};
45
46const variantClasses: Record<InlineEditVariant, string> = {
47 ghost:
48 'border border-transparent bg-transparent hover:bg-muted focus-visible:bg-muted dark:bg-transparent dark:hover:bg-muted',
49 boxed: 'border border-input bg-transparent shadow-xs focus-visible:border-ring',
50};
51
52function InlineEdit({
53 value,
54 onCommit,
55 input = 'text',
56 variant = 'ghost',
57 size = 'default',
58 placeholder = '—',
59 canEdit = true,
60 children,
61}: InlineEditProps) {
62 const [state, setState] = React.useState<State>({ kind: 'reading' });
63 const errorId = React.useId();
64
65 const fieldClassName = cn(
66 'w-full rounded-md text-left outline-none transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/50',
67 sizeClasses[size],
68 variantClasses[variant],
69 );
70
71 const startEdit = () => {
72 if (canEdit) setState({ kind: 'editing', draft: value });
73 };
74
75 const cancel = () => setState({ kind: 'reading' });
76
77 const setDraft = (draft: string) => setState((s) => (s.kind === 'editing' ? { kind: 'editing', draft } : s));
78
79 const commit = async (override?: string) => {
80// … truncated

What it pulls in

npm packages

  • @hookform/lenses
  • lucide-react
  • react
  • react-hook-form

Other registry items

  • field
  • input
  • popover
  • textarea

Files it writes

  • ./items/react-hook-form/inline-edit/component.tsx

Facts

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

Go to the source

Docs on shuip shuip.plvo.dev Raw registry item This item as JSON

More from shuip

All 52 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
confirmation-dialogconfirmation-dialogshuipComponentsFree1 dep
copy-buttoncopy-buttonshuipComponentsFree3 deps
hover-revealhover-revealshuipComponentsFree1 dep
rhf-address-fieldrhf-address-fieldshuipComponentsFree5 deps · 2 files
rhf-autocomplete-fieldrhf-autocomplete-fieldshuipComponentsFree4 deps
rhf-checkbox-fieldrhf-checkbox-fieldshuipComponentsFree3 deps
rhf-combobox-fieldrhf-combobox-fieldshuipComponentsFree5 deps
rhf-date-fieldrhf-date-fieldshuipComponentsFree6 deps
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