--- title: Create custom visual components category: Customize React Bricks order: 2 status: published summary: Use the useVisualEdit hook to build advanced custom editing components beyond Text, RichText, Image, and File. estimatedTime: 7 min keywords: usevisualedit custom visual components code editor custom editor advanced --- In this how-to, you'll learn how to create a custom visual editing component in React Bricks. This is an advanced technique. For most projects, the built-in visual components like `Text`, `RichText`, `Image`, `Link`, `File`, and `Repeater` are the right choice. Use a custom visual component only when you need an editing experience that React Bricks does not provide out of the box. Docs reference: [useVisualEdit](https://docs.reactbricks.com/api-reference/hooks/use-visual-edit/) ## When custom visual components are useful The `useVisualEdit` hook is the escape hatch for advanced editing UI. It is useful when you want to create things like: - a code editor - a JSON editor - a color palette picker - a canvas or drawing area - a custom form-like editor for one complex prop The hook lets your component read a brick prop and write back to that prop, while rendering a different UI depending on whether you are: - in the Admin editor - in Preview mode - on the public frontend ## What `useVisualEdit` returns The hook takes a prop name and returns: ```tsx const [value, setValue, isReadOnly] = useVisualEdit('myProp') ``` The returned values mean: - `value`: the current value of the prop - `setValue`: updates the prop - `isReadOnly`: `true` on the frontend and in Preview mode, `false` in the Admin editor That means your component usually has 2 render paths: - an editable UI for the Admin editor - a read-only UI for preview and frontend rendering ## A simple example: a custom code editor Here is a minimal example using a `textarea`. In a real project, you could swap this with Monaco, CodeMirror, a color picker, or another interactive editor. If you're using Next.js App Router, keep this editor as a client component. ```tsx {10,12,15,23} 'use client' import { useVisualEdit } from 'react-bricks/frontend' interface CodeEditorProps { propName: string } const CodeEditor = ({ propName }: CodeEditorProps) => { const [value, setValue, isReadOnly] = useVisualEdit(propName) if (isReadOnly) { return (
        {value || ''}
      
) } return (