This is a difficult question to answer as it depends on personal preference. Some people feel more comfortable in shorts while others find leggings to be a better option. There are pros and cons to both choices.
Shorts offer better ventilation and are cooler to wear in warm weather. They also allow full range of motion for your legs. On the downside, they provide less protection from the elements and can leave your legs more vulnerable to scratches and scrapes.
Leggings offer more coverage and protection from the elements, but can be hotter to wear in warm weather. They can also restrict movement somewhat compared to shorts. Ultimately, it comes down to what you feel most comfortable in when hiking.