AI Assistant Suite — 10 components for integrating AI capabilities into the PhiaUI rich text editor.
These components provide the visual UI layer for AI-powered editing features.
The actual AI logic is delegated to the PhiaUi.Editor.AiBridge behaviour,
which users implement with their preferred LLM provider.
Components
Chat & Suggestions
ai_sidebar/1— chat-like panel with message history + inputai_inline_suggestion/1— ghost text overlay for inline completionsai_autocomplete/1— dropdown suggestion list with keyboard nav
Content Transformation
ai_summary_card/1— card displaying AI-generated summaryai_rewrite_dialog/1— style-based rewriting with before/after previewai_translate_dialog/1— language translation with source/target pickersai_command_bar/1— sparkle-icon command input for freeform prompts
Analysis & Scoring
ai_tone_adjuster/1— range slider for formal ↔ casual toneai_grammar_check/1— list of grammar suggestions with accept/dismissai_content_score/1— clarity/engagement/readability progress bars
Summary
Functions
Renders a dropdown list of AI autocomplete suggestions.
Renders a command bar input with a sparkle icon for freeform AI prompts.
Renders three labeled progress bars for content quality scores.
Renders a list of grammar/style suggestions with accept/dismiss actions.
Renders an inline ghost-text suggestion overlay.
Renders a dialog for AI-powered text rewriting with style selection.
Renders a chat-like AI assistant panel with message history and input.
Renders a card displaying an AI-generated summary.
Renders a range slider for adjusting tone from Formal (0) to Casual (100).
Renders a translation dialog with source/target language dropdowns and text areas.
Functions
Renders a dropdown list of AI autocomplete suggestions.
Each suggestion is a string. The item at :selected_index is visually
highlighted. Use arrow keys + Enter to navigate/accept.
Example
<.ai_autocomplete
id="ai-complete"
suggestions={@completions}
visible={@show_completions}
selected_index={@completion_index}
/>Attributes
id(:string) (required)suggestions(:list) - Defaults to[].visible(:boolean) - Defaults tofalse.selected_index(:integer) - Defaults to0.class(:string) - Defaults tonil.- Global attributes are accepted.
Renders a command bar input with a sparkle icon for freeform AI prompts.
Hidden when :visible is false. The input fires phx-submit="ai:command"
with the query text.
Example
<.ai_command_bar id="ai-cmd" editor_id="my-editor" visible={@show_ai_bar} />Attributes
id(:string) (required)editor_id(:string) (required)visible(:boolean) - Defaults tofalse.query(:string) - Defaults to"".class(:string) - Defaults tonil.- Global attributes are accepted.
Renders three labeled progress bars for content quality scores.
Expects :scores to be a map with optional keys :clarity, :engagement,
and :readability, each 0-100.
Example
<.ai_content_score
id="score"
scores={%{clarity: 85, engagement: 72, readability: 91}}
/>Attributes
id(:string) (required)scores(:map) - Defaults to%{}.class(:string) - Defaults tonil.- Global attributes are accepted.
Renders a list of grammar/style suggestions with accept/dismiss actions.
Each item in :suggestions should be a map with :text (original),
:suggestion (replacement), and :type (:grammar, :spelling, :style).
Example
<.ai_grammar_check
id="grammar"
suggestions={[
%{text: "their", suggestion: "there", type: :grammar},
%{text: "alot", suggestion: "a lot", type: :spelling}
]}
/>Attributes
id(:string) (required)suggestions(:list) - Defaults to[].class(:string) - Defaults tonil.- Global attributes are accepted.
Renders an inline ghost-text suggestion overlay.
The suggestion appears as dimmed text that the user can accept (Tab) or
dismiss (Escape). Visibility is controlled by the :visible attr.
Example
<.ai_inline_suggestion id="ghost" suggestion="the quick brown fox" visible={@show_suggestion} />Attributes
id(:string) (required)suggestion(:string) - Defaults to"".visible(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.- Global attributes are accepted.
Renders a dialog for AI-powered text rewriting with style selection.
Displays a row of style buttons, the original text, and the rewritten result.
The user selects a style which triggers a phx-click="ai:rewrite" event.
Example
<.ai_rewrite_dialog
id="rewrite"
visible={@show_rewrite}
original_text={@selected_text}
rewritten_text={@rewritten}
selected_style={@rewrite_style}
loading={@rewriting}
/>Attributes
id(:string) (required)visible(:boolean) - Defaults tofalse.styles(:list) - Defaults to[:professional, :casual, :concise, :detailed, :creative].selected_style(:atom) - Defaults tonil.original_text(:string) - Defaults to"".rewritten_text(:string) - Defaults to"".loading(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.- Global attributes are accepted.
Renders a chat-like AI assistant panel with message history and input.
Each message in the :messages list should be a map with :role (:user or
:assistant) and :content (string) keys.
Example
<.ai_sidebar id="ai-chat" messages={@ai_messages} loading={@ai_loading} />Attributes
id(:string) (required)messages(:list) - Defaults to[].loading(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.- Global attributes are accepted.
Renders a card displaying an AI-generated summary.
Shows a loading skeleton when :loading is true, otherwise displays the
summary text.
Example
<.ai_summary_card id="summary" summary={@ai_summary} loading={@summarizing} />Attributes
id(:string) (required)summary(:string) - Defaults to"".loading(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.- Global attributes are accepted.
Renders a range slider for adjusting tone from Formal (0) to Casual (100).
Fires phx-change="ai:tone" with the slider value.
Example
<.ai_tone_adjuster id="tone" value={@tone_value} />Attributes
id(:string) (required)value(:integer) - Defaults to50.class(:string) - Defaults tonil.- Global attributes are accepted.
Renders a translation dialog with source/target language dropdowns and text areas.
Example
<.ai_translate_dialog
id="translate"
visible={@show_translate}
original_text={@selected_text}
translated_text={@translated}
source_lang={@source_lang}
target_lang={@target_lang}
loading={@translating}
/>Attributes
id(:string) (required)visible(:boolean) - Defaults tofalse.languages(:list) - Defaults to["English", "Spanish", "French", "German", "Portuguese", "Chinese", "Japanese"].source_lang(:string) - Defaults tonil.target_lang(:string) - Defaults tonil.original_text(:string) - Defaults to"".translated_text(:string) - Defaults to"".loading(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.- Global attributes are accepted.