By default, iCloud keeps a local copy on your Mac. Both iCloud Photos and iCloud Drive have options that may reduce the local space used. For iCloud Photos, the option is in the Photos app Preferences menu, click iCloud at the top of the Preferences window and then click Optimize Mac Storage. For iCloud Drive, the option is at Apple menu > System Preferences > Apple ID > iCloud (on the left sidebar) > Optimize Mac Storage (near the bottom of the main window on the right).
More information on both options:
From Set up and use iCloud Photos - Apple Support
If you turn on Optimize Storage, iCloud Photos automatically manages the size of your library on your device. Your original photos and videos are stored in iCloud and space-saving versions are kept on your device. Your library is optimized only when you need space, starting with the photos and videos you access least. You can download the original photos and videos over Wi-Fi or cellular when you need them.
and
From How to free up storage space on your Mac - Apple Support
Desktop and Documents. Store all files from these two locations in iCloud Drive. When storage space is needed, only the files you recently opened are kept on your Mac, so that you can easily work offline. Files stored only in iCloud show a download icon
, which you can double-click to download the original file. Learn more about this feature.
Photos. Store all original, full-resolution photos and videos in iCloud Photos. When storage space is needed, only space-saving (optimized) versions of photos are kept on your Mac. To download the original photo or video, just open it.