Introducing PrimeReact v11-alpha 🎉Discover Now

Inplace

An unstyled, accessible inline editing component with compound composition.

Build fully custom inline display-to-edit experiences with complete control over layout and styling.

Click to edit
basic-demo

Pre-styled Versions

Choose a pre-styled library to use Inplace with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Compound component API with four sub-components: Root, Display, Content, Close

Usage#

import { Inplace } from 'primereact/inplace';
<Inplace.Root>
    <Inplace.Display></Inplace.Display>
    <Inplace.Content>
        <input />
        <Inplace.Close></Inplace.Close>
    </Inplace.Content>
</Inplace.Root>

Behavior#

Polymorphic Rendering#

Use as on any sub-component to change the rendered HTML element.

<Inplace.Close as="button">Done</Inplace.Close>

Default elements: Root=div, Display=div, Content=div, Close=div.

Render Function Children#

Content accepts a render function as children, providing access to the component instance.

<Inplace.Content>{(instance) => <span>Active: {String(instance.inplace?.state.active)}</span>}</Inplace.Content>

Pass Through#

Some parts may not be visible in the preview depending on the component's current state.

Loading...
/* Select a part to see its CSS selector for custom styling */

API#

InplaceRoot#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: InplaceRootInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: InplaceRootInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceInplaceRootInstance—
The instance to pass to the component.
ptSafeRecord<InplaceRootPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: InplaceRootInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
activebooleanfalse
Whether the content is displayed or not.
defaultActivebooleanfalse
Whether the content is displayed or not.
disabledbooleanfalse
When present, it specifies that the element should be disabled.
onActiveChange(event: InplaceRootChangeEvent) => void—
Callback fired when the Inplace's active state changes.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"inplace"
data-part"root"
data-activePresent when active
data-inactivePresent when inactive
data-disabledPresent when disabled

Defines passthrough(pt) options of Inplace component.

labeltypedescription
rootInplaceRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
contentInplaceRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the content's DOM element.
displayInplaceRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the display's DOM element.
closeInplaceRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the close's DOM element.

InplaceDisplay#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: InplaceDisplayInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: InplaceDisplayInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceInplaceDisplayInstance—
The instance to pass to the component.
ptSafeRecord<InplaceDisplayPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: InplaceDisplayInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"inplace"
data-part"display"
data-activePresent when active
data-inactivePresent when inactive
data-disabledPresent when disabled

Defines passthrough(pt) options of InplaceDisplay component.

labeltypedescription
rootInplaceDisplayPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

InplaceContent#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: InplaceContentInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: InplaceContentInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceInplaceContentInstance—
The instance to pass to the component.
ptSafeRecord<InplaceContentPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: InplaceContentInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of InplaceContent component.

labeltypedescription
rootInplaceContentPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

InplaceClose#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: InplaceCloseInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: InplaceCloseInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceInplaceCloseInstance—
The instance to pass to the component.
ptSafeRecord<InplaceClosePassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: InplaceCloseInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"inplace"
data-part"close"
data-activePresent when active
data-inactivePresent when inactive
data-disabledPresent when disabled

Defines passthrough(pt) options of InplaceClose component.

labeltypedescription
rootInplaceClosePassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

Inplace uses aria-live="polite" by default so screen readers announce content changes. The display element has tabIndex={0} for keyboard focus.

Keyboard Support#

KeyFunction
enterActivates the display, showing the content.
spaceActivates the display, showing the content.