A method to estimate the index of refraction in warm and hot dense matter is proposed. This method combines the Kubo-Greenwood approach, Maxwell equations, and existing codes that calculate photoabsorption and photoemission coefficients in warm and hot dense plasmas. An effective electrical conductivity is calculated from existing opacity codes from which the index of refraction is derived. Illustrations are shown on specific examples.