A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
Dear Lourenco Freire,
Good day! Thank you for posting to Microsoft Community. We are happy to help you.
As per your description, "I added a document library to my sharepoint page" may I know are you add a document library webpart on your SharePoint online page?
It seems you want to only give users access to view specific columns of document library.
By default, a view inherit permissions from the list/library. Unfortunately lists/document libraries views does not provide the ability to set specific permissions. Views have never been a securable object in SharePoint.
As a workaround, you may Edit a default SharePoint document view and hide columns that you don't want to see the users and save the customized view as a default and in this scenario, when user access document library on a page they can only see specific columns.
Also, use audience targeting feature to display the webpart to certain set of users.
Regarding to, "I want to control in the document library only specific groups can access specific folders" It is possible to break permission inheritance on a folder in SharePoint and set unique permissions, letting you prevent users from accessing a specific folder in SharePoint.
For your reference: SharePoint site permissions
Your understanding and patience will be highly appreciated. I hope that you are keeping safe and well!
Sincerely,
Waqas Muhammad
***Note: In the event that you're unable to reply to this thread, please ensure that your Email address is verified in the Community Website by clicking on Your Account Name > "My Profile" > "Edit Profile" > Add your Email Address > tick "Receive email notifications" checkbox > click on "Save".***