Hi @NS,
As the script editor web part is not supported in modern SharePoint, we are unable to insert CSS or JavaScript directly. We have to use SPFx based react script editor web part to add custom CSS or JavaScript to modern SharePoint Online pages.
Reference:
- Build your first SharePoint Framework Extension.
- Inject Custom CSS on SharePoint Modern Pages using SPFx Application Extensions.
- Step By Step Procedure To Add A JS File To All Pages In A SPFx Modern Pages Using SharePoint Framework Extension.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.