Hiyve Components - v1.0.0
    Preparing search index...
    • Generate a consistent avatar color based on a userId.

      Parameters

      • userId: string | undefined

        The user ID to generate a color for

      • palette: string[] = DEFAULT_AVATAR_PALETTE

        Array of colors to choose from (defaults to DEFAULT_AVATAR_PALETTE)

      Returns string

      A color from the palette, deterministic for the same userId

      Uses a hash function to ensure the same userId always maps to the same color, providing visual consistency across sessions and components.

      getUserColor('user-123')                    // consistent color from default palette
      getUserColor('user-123', ['#f00', '#0f0']) // consistent color from custom palette
      getUserColor(undefined) // first color in palette