Forum Discussion
badamsSP
Mar 20, 2020Copper Contributor
SharePoint List - Custom JSON Column Formatting - Office UI Fabric Icon for Any Selected Value?
Hi all - first post of hopefully not too many!
I manage a number of SharePoint lists and am familar with using basic JSON formatting to display custom colours and icons from the Office UI Fabric.
If I have a choice field, I know how to show a given icon from the Office UI Fabric, but is there a way to show the same icon regardless of the value displayed in the field?
For example, if you had a choice field called 'Location' and you had 100 locations to choose from, you might want the 'POI' or 'MapPin' icon to display regardless of which option is chosen? To write the JSON for each and every option just seems so long!
Hope somebody can help!
Many thanks in advance
- RobElliottSilver Contributor
Hi badamsSP, you can use the following JSON to format your column so that each item shows the same icon, for example the MapPin:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "attributes": { "class": "sp-field-severity--good" }, "children": [ { "elmType": "span", "style": { "display": "inline-block", "padding": "12px 4px" }, "attributes": { "iconName": "MapPin" } }, { "elmType": "span", "txtContent": "@currentField" } ] }
Rob
Los Gallardos
Microsoft Power Automate Community Super User