A liberal would never elect a conservative and vice versa, but there's an expectation to maintain the court's approximate balance (which is why Scalia's death is such a big deal). So if a very right-leaning justice stepped down under a liberal president, he'd elect a center / center-left justice. If the most left-wing justice in the world stepped down, then a left-wing president could elect the most left-leaning person.
By no means a rule, but a tradition at least.