In this article, an alterable structural color in the reflected light of a chiral nematic imprinted film was fabricated. Biotemplate nanocrystalline celluloses were applied as structural oriented templates. Selectivity of the sensor was endowed by the molecular imprinting process which applied sulfamethoxazoles (SMXs) as template molecules, urea and phenol as double functional monomers, and formaldehyde as cross-linkers. The sensor exhibited a chiral nematic blue mesoporous structure, which could selectively recognize SMXs on account of the abundant predetermined rebinding sites. Once SMXs were detected, the sensor showed a visible color variance from blue to yellow and the sensitive concentration range was from 3.9 × 10-3 to 3.9 mmol L-1. Both quantitative analyses, selective testing and recycling performance of the sensor were demonstrated. This optical response to SMXs can provide a portable, low-cost and easy-to-use strategy for the convenient detection of SMXs.