# Editable URL: https://ark-ui.com/docs/components/editable Source: https://raw.githubusercontent.com/chakra-ui/ark/refs/heads/main/website/src/content/pages/components/editable.mdx A component that allows users to edit text in place. --- ## Anatomy ```tsx ``` ## Examples **Example: basic** ```ripple import { Editable } from 'ark-ripple/editable'; import { Pencil } from 'lucide-ripple'; import styles from 'styles/editable.module.css'; export component Basic() { {'Label'} } ``` ### Controlled Use the `value` and `onValueChange` props to control the editable state. **Example: controlled** ```ripple import { Editable } from 'ark-ripple/editable'; import { Pencil } from 'lucide-ripple'; import { track } from 'ripple'; import styles from 'styles/editable.module.css'; export component Controlled() { let value = track('Hello World'); { @value = e.value; }} > {'Label'} } ``` ### Root Provider An alternative way to control the editable is to use the `RootProvider` component and the `useEditable` hook. This way you can access the state and methods from outside the component. **Example: root-provider** ```ripple import { Editable, useEditable } from 'ark-ripple/editable'; import { Pencil } from 'lucide-ripple'; import styles from 'styles/editable.module.css'; export component RootProvider() { const editable = useEditable({ defaultValue: 'Hello World' }); {'Label'} } ``` ### Context Access the editable's state with `Editable.Context` or the `useEditableContext` hook—great for showing keyboard hints when editing. **Example: context** ```ripple import { Editable } from 'ark-ripple/editable'; import { Pencil } from 'lucide-ripple'; import styles from 'styles/editable.module.css'; export component Context() { {'Label'} component children({ context }) { if (@context.editing) { {'Enter to save, Esc to cancel'} } else { } } } ``` ### Controls In some cases, you might need to use custom controls to toggle the edit and read mode. We use the render prop pattern to provide access to the internal state of the component. **Example: controls** ```ripple import { Editable } from 'ark-ripple/editable'; import { Check, Pencil, X } from 'lucide-ripple'; import styles from 'styles/editable.module.css'; export component Controls() { {'Label'} component children({ context }) { if (@context.editing) { } else { } } } ``` ### Textarea Use the `asChild` prop on `Editable.Input` to render a textarea for multi-line editing. **Example: textarea** ```ripple import { Editable } from 'ark-ripple/editable'; import styles from 'styles/editable.module.css'; export component WithTextarea() { {'Description'} component asChild({ propsFn }) {