Suggestions
Inline AI edit suggestions over a body of text. The AI marks spans with a colored dotted underline; click one to see the proposed replacement and a reason, then apply it in place or dismiss it.
Installation#
Usage#
import { Suggestions, SuggestionMark } from "@/components/ui/suggestions"
export function Review() {
return (
<Suggestions onApply={(next, original) => save(next)}>
The deadline is{" "}
<SuggestionMark
variant="grammar"
suggestion="Friday"
reason="Capitalize the day of the week."
>
friday
</SuggestionMark>
.
</Suggestions>
)
}Wrap each improvable span in a SuggestionMark with its suggestion (the replacement) and an optional reason. Applying swaps the children for the suggestion in place; dismissing keeps the original. Both fire the root's onApply / onDismiss so you can persist the edit or tick down a counter.
Categories#
The variant tints the underline and the popover badge, so a reader can tell a grammar fix from a tone or clarity nudge at a glance: grammar, clarity, tone, and a neutral default.
API reference#
Suggestions
The prose container and context for the marks. Forwards all native div props.
onApply?(suggestion, original): fired when any mark is applied.onDismiss?(original): fired when any mark is dismissed.
SuggestionMark
One improvable span. The children are the original text; applying replaces them with suggestion.
suggestion: the replacement text (required).variant?:default·grammar·clarity·tone.label?/reason?: the popover badge text and one-line explanation.onApply? / onDismiss?: per-mark hooks (the root's run too).