{"id":"48ae5edce23f3b02de28aeda69a13758fe5118eed8c12118998d008d8034a70d","pubkey":"a563ca9a16d744b98f39ff421eb7002a8ea21140d9c14ffca8b645d2ae8d718c","created_at":1777595013,"kind":30817,"tags":[["d","profile-colors"],["title","Profile Colors"],["k","0"],["client","nostrhub.io"]],"content":"NIP-XX\n======\n\nProfile Colors\n--------------\n\n`draft` `optional` `ui`\n\nA standard for deriving deterministic, readable colors from Nostr pubkeys. This ensures consistent visual identity across all clients.\n\n## Abstract\n\nNostr apps often use random colors for default avatars, profile names, and chat bubbles. This NIP proposes deriving a unique, consistent color from each user's pubkey instead — one that is readable in both light and dark modes, and avoids grays.\n\n## Motivation\n\nCurrently, clients generate profile colors inconsistently. Different algorithms produce different colors for the same pubkey, fragmenting the user experience.\n\nStandardizing pubkey-derived colors:\n- Ensures **consistent identity** across all clients\n- Provides **predictable, reproducible** colors\n- Works as text, background, border, or indicator dot without extra UI elements\n\n## Color Derivation\n\n### Algorithm\n\n1. Convert the 64-character hex pubkey to an integer\n2. Calculate the **Hue**: `integer % 360`\n3. Set **Saturation** to `70%`\n4. Set **Value/Brightness** based on Hue range:\n\n| Hue Range | Brightness |\n|-----------|------------|\n| 32–204    | 75%        |\n| 216–273   | 96%        |\n| Otherwise | 90%        |\n\n5. Convert HSV to the desired format (RGB, Hex, HSL, etc.)\n\n### Text Readability\n\nWhen using the profile color for text (author names, mentions, etc.), adjust brightness:\n\n- **Dark mode**: increase brightness by `+8%`\n- **Light mode**: decrease brightness by `-5%`\n\nThis ensures readable text in both modes without runtime luminance calculations.\n\n## Example\n\nGiven pubkey `a1b2c3d4e5f6...`:\n\n1. Convert to integer: `461184877...`\n2. Hue: `461184877 % 360 = 197`\n3. Saturation: `70%`\n4. Hue 197 is in range 32–204 → Brightness: `75%`\n5. HSV(197, 70%, 75%) → RGB\n\n## Client Behavior\n\nClients SHOULD:\n- Use the derived color for default avatars, profile names, and indicators when no profile picture is available\n- Apply text brightness adjustments for the current theme (light/dark)\n- Support the color as background, text, border, or dot indicator\n\nClients MAY:\n- Use the color as a placeholder while loading a profile picture\n- Use the color as fallback if the profile picture URL fails to load","sig":"b5fa2138ba9907a7af2b01f6a0d038c5061fab34b66c034551711661c9c587bf9761218d422e72504fce5ee697f4dadd51cd5baea4e1e622af600c8dabcdb7bf"}