Adding a new dimmer switch to old wiring?
The white wire to the switch should be the hot feed if it is wired according to code. Connect the white wire to the top black wire on your dimmer and connect the black wire from the cable to the other black wire. Connect the green to the bare wire on the cable (and to the box if it is metal.)

Make sure your light fixtures are dimmable and the dimmer is the right one for the type of lighting you have.