This is assuming you are using the photos app for your photos.
1 - you need an iCloud plan with enough storage for your entire library.
2 - Enable iCloud, and choose "optimise mac storage|". Optimise mac storage will move all your original files to iCloud, keeping small previews and thumbnails on your mac. This dramatically reduces the storage required, but it will still take some (around 10 to 20% of your current library size). The advantage of this is it will continue to allow you to use the photos app to view and edit images as though they are stored locally.
There is no easy option within the Photos/iCloud environment to completely store the images only in iCloud except as noted above.