In this article, we will see how we can make a single line of text column's values be displayed as a hyperlink with icon and how to create a dynamic href. Suppose you have an email field in your list which is a single line of text. Single line of text values will be displayed as normal text in SharePoint modern views.
Scenario
Suppose you have custom list name 'Xyz' and it has one column named 'Email' which is a single line of text (due to business requirements you have not chosen to use people and group or you are storing some external user's email id in this column). Now when you see this in Default list view it would be displayed like below.

Now you need to make this Email column values clickable so that on click it opens an email client new mail window with 'To' field pre-populated. We will have to just customize this field to display it as anchor tag with href set to mailto:'[email protected]'.
We have 2 options to achieve this:
- Using SPFx extension Field customizer
- Using Column Formatting option
The first one would need you to create a package and write custom code, so here we will use the second option using the Column formatting option.
Microsoft has introduced column and view formatting to let us control how default list views are displayed. We won't be able to change the value of fields but we will be able to change its formatting. Now let us see how can we achieve this.
Go to List Settings -> Edit Column 'Email' - Find option Column formatting,

Add the below Json inside text area.
- {
- "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
- "elmType": "div",
- "children": [
- {
- "elmType": "a",
- "style": {
- "padding-right": "8px"
- },
- "txtContent": "@currentField",
- "attributes": {
- "target": "_blank",
- "href": {
- "operator": "+",
- "operands": [
- "mailto:",
- "@currentField",
- "?subject=Wonder women here&body=Hey ",
- "[$Title]",
- "\nJust checking, if you have saved the world?.\r\n---\r\n",
- "\r\nClick this link for more info. http://contoso.sharepoint.com/sites/ConferencePrep/Tasks/Prep/DispForm.aspx?ID=",
- "[$ID]"
- ]
- }
- }
- },
- {
- "elmType": "a",
- "attributes": {
- "target":"_blank",
- "iconName": "Mail",
- "class": "sp-field-quickActions",
- "href": {
- "operator": "+",
- "operands": [
- "mailto:",
- "@currentField",
- "?subject=Wonder women here&body=Hey ",
- "[$Title]",
- "\nJust checking, if you have saved the world?\r\n---\r\n",
- "\r\nClick this link for more info. http://contoso.sharepoint.com/sites/ConferencePrep/Tasks/Prep/DispForm.aspx?ID=",
- "[$ID]"
- ]
- }
- }
- }
- ]
- }


SergioPosted Dec 15, 2022, 9:43 PM
Wonderful article. Thank you! can you please show how to add a column value for the mailto subject ? I tried replacing the "wonder women here" text with [$ID] - [$RequestSubject] but it just rendered the brackets and text instead of placing its values
Books ReadPosted Feb 3, 2021, 5:23 PM
Hello Siddharth , i have multi value people picker field with holds hundreds of names.Is it possible to show these names in new window and show only few names in the column by default.
Kati DavidsPosted Dec 16, 2020, 2:21 PM
I am wondering if you could provide the code for turning the current single line of text (which currently it the URL in plain text- its just not hyperlinked) into a hyperlink. The code you provided is for opening email etc, i need something more basic.