A star like our Sun will become a white dwarf when it has run out of fuel. Near the end of its life, it will go through a red giant stage, and then lose most of its gas, until what is left contracts and becomes a young white dwarf.