Sandberg, whose husband, Dave Goldberg, died in a treadmill accident while on vacation last year in Mexico, said she was "swallowed up in the deep fog of grief."
"Dave's death changed me in very profound ways," she told 4,700 graduating seniors. "I learned about the depths of sadness and the brutality of loss. But I also learned that when life sucks you under, you can kick against the bottom, break the surface and breathe again."
Losing her husband helped her find deeper gratitude for the kindness of her friends, the love of her family and the laughter of her children. She realized that in the face of any challenge, one can choose joy and meaning, Sandberg told the crowd.
"It is the greatest irony of my life that losing my husband helped me find deeper gratitude," she said.
Sandberg encouraged UC Berkeley's 2016 graduating class to build resilience in themselves, their places of work and their communities. "When the challenges come, I hope you remember that anchored deep within you is the ability to learn and grow," she said.
Click here for more stories on Sheryl Sandberg.