SharePoint Online Code snippet web part

In this SharePoint modern tutorial, we will discuss everything about the SharePoint Online Code snippet web part and how to add and configure the code snippet web part.

The Code snippet web part is not available in SharePoint Server 2019.

What is SharePoint Online Code snippet web part?

  • Using the Code snippet web part, we can easily show the code on our SharePoint page, when we add the code snippet web part to the SharePoint page by default it shows javascript code language with the dark theme.
  • We cannot execute the code in the code snippet web part, it is used to display the code on the modern SharePoint page.
  • TypeScript, SQL, Scala, Python, Powershell, Objective C, Markdown, Javascript, Java, HTML, Go, Diff, CSS, C#, C++, and C. These are the programming language that we can display in the code snippet web part.
  • We can also change the theme in the code snippet web part, we can add a single line code or multi-lines of code.
  • Code snippet web is available both in the modern SharePoint team site and communication sites. The Code snippet web part is not available in SharePoint Server 2019.

Also read, SharePoint Highlighted content web part

How to add Code snippet web part in SharePoint online

Let us see how to add and edit a Code snippet web part in the modern SharePoint,

  • Open the SharePoint site page -> Select Edit Page of the SharePoint site page.
  • Click on the + circled icon to add a Section layout -> Choose the Code snippet web part.
add a code snippet web part in modern SharePoint
add a code snippet web part in modern SharePoint

In the below screenshot, we can see the code snippet web part is added. If we edit the code snippet web part we can see the option to wrap code lines.

edit code snippet web part in modern SharePoint
edit code snippet web part in modern SharePoint

This is how we can add and edit a code snippet web part in the modern SharePoint online.

Read SharePoint Online Weather Web Part

SharePoint online code snippet web part features

Let us discuss what are features available in the Code snippet web part in the modern SharePoint,

We can select the following programming language, that we want to display in the code snippet web part, TypeScript, SQL, Scala, Python, Powershell, Objective C, Markdown, Javascript, Java, HTML, Go, Diff, CSS, C#, C++, and C.

Code snippet web part features
Code snippet web part features
  • We can also select the Numbered lines or Unnumbered lines in the code snippet web part, we can add a single line code or multi-lines of code.
  • If we want to display code with a line number, then we can select the numbered lines option else we can select the unnumbered lines option. By default, it will be in numbered lines option.
  • We can also change the theme in the code snippet web part, By default, it will be in Dark theme mode.
  • Select Republish to save your changes.
  • Once the modern SharePoint page is published, we cannot modify the code available in the code snippet web part.

The below screenshot displays the Numbered lines in the SharePoint online code snippet web part.

Code snippet web part features in sharepoint online
Code snippet web part features in SharePoint online

The below screenshot displays the Unnumbered lines in the SharePoint online code snippet web part.

Code snippet web part features in sharepoint
Code snippet web part features in SharePoint

The below screenshot displays the Dark theme of the code snippet web part in modern SharePoint.

Code snippet web part features in modern sharepoint
Code snippet web part features in modern SharePoint

The below screenshot displays the Light theme of the code snippet web part in modern SharePoint.

Code snippet web part features in the sharepoint online
Code snippet web part features in the SharePoint online

These are some features available in the Code snippet web part in the modern SharePoint.

Related SharePoint web part tutorials:

In this SharePoint modern tutorial, we learned what is a SharePoint Online Code snippet web part. We also learned about the code snippet web part features in the modern SharePoint online.

>