Compose structured prompts with a reusable rich text editor.
import { useState } from 'react';
import { RichPromptInput } from '@vrum/ui';
import type { JSONContent } from '@vrum/ui';
export default function Demo() {
const [value, setValue] = useState<JSONContent>({"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Write a project update for the team."}]}]});
return (
<RichPromptInput
value={value}
disabled={false}
placeholder={"Write a detailed prompt…"}
hiddenToolbarItems={[]}
onChange={setValue}
onSubmit={(text) => console.log(text)}
/>
);
}Copy code| Prop | Type | Default | Description |
|---|---|---|---|
value | JSONContent | none | Controlled value; connect the callback to application state. |
defaultValue | JSONContent | none | Initial value for an uncontrolled component. |
onChange | ((value: JSONContent) => void) | none | Called when the input value changes. |
onSubmit | ((text: string) => void) | none | Called when the form is submitted. |
onImprovePrompt | ((text: string) => void) | none | on improve prompt configuration. |
disabled | boolean | false | Disable user interaction. |
placeholder | string | "Write a detailed prompt…" | Hint shown when no value is entered. |
hiddenToolbarItems | ("bold" | "italic" | "bulletList" | "orderedList" | "improve")[] | [] | hidden toolbar items configuration. |
defaultChecked | boolean | none | default checked configuration. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLDivElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLDivElement> | none | on blur configuration. |
onKeyDown | KeyboardEventHandler<HTMLDivElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLDivElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLDivElement> | none | on select configuration. |