An ordinary set of 3-way switches consists of 2 switches, with one switch connected to the incoming hot, one switch connected to the switched hot, and a 3-wire cable going between them with 2 of the 3 wires connected to both switches as travelers and the third wire one of:
depending on design.
There are also some ways to wire "3-way" switches using smart switches where there are only two wires between the switches, or the switches aren't even connected at all, with one of them being either a line-powered (so needs power but not necessarily same circuit as the other switch) or battery-powered switch.
Based on the picture and description, this is most likely not a 3-way setup.
Assuming it is a regular single dimmer switch with three cables, there are a few ways to wire it up. But we can pretty much rule out "old style two wire switch loop" because typically with those you only see one cable in the switch box. Which means the likely setup is:
- One cable coming in from the panel (or earlier in the circuit) with hot and neutral
- One cable going to the light fixture with switched hot and neutral
- One cable going to another switch or receptacle or other device
To figure this out:
- Carefully separate all the black wires
- Turn on the breaker
- Use a non-contact voltage meter and/or a multimeter to determine which wire is hot. Only one should be hot when the wires are disconnected. If you find more than one hot (NCVT detects voltage and/or multimeter shows ~ 120V between wire and ground/metal box) then STOP.
- Turn off the breaker. Mark the hot wire so you know what's what.
- Connect the hot wire to one of the other black wires.
- Turn on the breaker and see if the light goes on. If it does, that is the switched hot. Turn off the breaker.
- If you didn't yet find the switched hot, connect the other black wire to the hot wire and turn on the breaker to test it.
- If you have identified switched hot, you are nearly done. If not, STOP.
- The remaining black wire is ongoing hot to something else. There is almost certainly something else in your house currently not working...
Unless you had a hard STOP above (in which case describe what happened and we'll try to help):
- Connect hot and ongoing hot together with a short piece of 12 AWG (if 15A or 20A circuit breaker) or 14 AWG (if 15A circuit breaker) black wire using a wire nut. Connect the other end to the dimmer. If the dimmer has two "whatever" connections then pick one. If one is labeled "hot" or "line" or "in", that's where this wire goes.
- Connect switched hot to the other end of the dimmer. If the dimmer has two "whatever" connections then just use the one you didn't use before (obviously). If one is labeled "load" or "switched" or "out", that's where this wire goes.
If you want to install a new switch that requires neutral, you get that by removing the blue wire nut from the white wires and adding a new short piece of white wire (12 AWG or 14 AWG as above) and putting on a wire nut and connecting the other end of the white wire to your switch "neutral" screw.