AI Prompt Quality Meter
Real-time prompt quality analysis with breakdown by clarity, specificity, context, structure, and length. Provides actionable suggestions to improve prompt effectiveness.
Preview - Low Quality Prompt
Analysis of a brief, vague prompt
Prompt Quality
Needs improvement
Clear and understandable
Could use more detail
More context would help
Could be better organized
Too short
Tips to improve
High Quality Prompt
Well-structured prompt with good scores
Prompt Quality
Excellent prompt!
Clear and understandable
Could use more detail
More context would help
Well-organized
Good length
Tips to improve
Compact Mode
Minimal display without breakdown
Without Suggestions
Show scores only, no improvement tips
Prompt Quality
Needs improvement
Clear and understandable
Could use more detail
More context would help
Could be better organized
Too short
Props
AIPromptQualityMeter component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
prompt* | string | — | The prompt text to analyze |
scores | QualityScore[] | — | Pre-computed quality scores (optional - will estimate if not provided) |
goodThreshold | number | 70 | Overall quality threshold for "good" (0-100) |
showBreakdown | boolean | true | Show individual factor breakdowns |
showSuggestions | boolean | true | Show improvement suggestions |
compact | boolean | false | Compact display mode |
live | boolean | true | Live update as user types |
onSuggestionClick | (factor: QualityFactor, suggestion: string) => void | — | Callback when user clicks a suggestion |
className | string | — | Additional CSS classes |
QualityScore Type
| Prop | Type | Default | Description |
|---|---|---|---|
factor* | 'clarity' | 'specificity' | 'context' | 'structure' | 'length' | — | Quality factor being measured |
score* | number | — | Score from 0-100 |
feedback | string | — | Feedback for this factor |
suggestion | string | — | Suggestion for improvement |
Usage
Import and implementation example
import { AIPromptQualityMeter } from '@/blocks/ai-transparency/ai-prompt-quality-meter'import { useState } from 'react'
export default function Example() { const [prompt, setPrompt] = useState('')
return ( <div> <textarea value={prompt} onChange={(e) => setPrompt(e.target.value)} placeholder="Enter your prompt..." className="w-full p-3 border rounded-lg" />
<AIPromptQualityMeter prompt={prompt} showBreakdown={true} showSuggestions={true} onSuggestionClick={(factor, suggestion) => { console.log(`Improve ${factor}: ${suggestion}`) }} /> </div> )}Features
Built-in functionality
- Five quality factors: Clarity, specificity, context, structure, and length
- Real-time analysis: Updates as user types (optional)
- Overall score: Aggregate score with color-coded status
- Factor breakdown: Individual progress bars for each factor
- Actionable suggestions: Specific tips to improve each low-scoring factor
- Heuristic analysis: Built-in prompt analysis algorithm
- Custom scoring: Override with your own quality scores
- Compact mode: Minimal progress bar for tight spaces
- Dark mode support: Full dark mode with proper contrast
Quality Factors Explained
What each factor measures
Clarity
How clear and understandable is the request. Good clarity means starting with question words or clear action verbs.
Specificity
How specific and detailed is the request. Includes concrete requirements, constraints, or examples.
Context
How much relevant context is provided. Background information helps the AI understand the situation.
Structure
How well-organized is the prompt. Using bullet points, numbering, or clear sections improves structure.
Length
Is the prompt length appropriate. Optimal range is 10-100 words (too short lacks detail, too long may be unfocused).
Accessibility
ARIA support and keyboard navigation
ARIA Attributes
Progress bars have implicit progress roleScores are displayed both as numbers and visual barsColor is not the only indicator (icons and text are used)Keyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between suggestion buttons |
| Enter | Activate suggestion to learn more |
Notes
- Consider adding aria-label to describe overall quality
- Ensure sufficient contrast for all score colors
- Suggestions should be keyboard accessible
- Screen readers should announce score changes
- Live regions could announce quality updates as user types