That's a somewhat common problem that is usually caused by an intermittent connection at the back of the instrument cluster. If that's what is causing yours, and I would be it it is, it is fairly easily fixed. You can sometimes confirm this is the cause of that problem by seeing if the instruments come back on after a good sharp whack to the top of the cluster with the flat of your hand.
There are two multi-pin connectors on the backside of the instrument cluster and their design isn't exactly bulletproof. The usual fix is to remove the instrument cluster (an easy 5-10 minute job) and then very slightly/gently tweak (bend) each of the male contact pins so they fit more tightly & then reconnect the connectors.
Here's a writeup that may help...
TJ Jeep Problem with Instrument Guages.