HomeAboutAll PostsVideosSearchRSS

Reusable SharePoint CSS classes

By Denis Molodtsov
Published in SharePoint
April 02, 2024
1 min read
Reusable SharePoint CSS classes
Table of contents

Introduction

Hi, fellow SharePoint developers and power users! 🤓

Are you working with the SharePoint Framework (SPFx), or must you style SharePoint lists with JSON formatting? Then you might want to know that there is a collection of all reusable CSS classes available on a single page: https://zerg00s.github.io/sp-modern-classes

SharePoint

How do I use these CSS classes?

Column formatting, view formatting, form formatting

You can use column and view formatting to customize how fields in SharePoint lists and libraries are displayed. To do this, you construct a JSON object that describes the elements that are displayed when a field is included in a list view, and the styles to be applied to those elements.

Sample JSON formatting for a SharePoint Title field:

  • Format a column

alt text
alt text

  • Advanced mode

alt text
alt text

  • Apply a sample sp-field-dataBars CSS class to the Title field:
json
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "sp-field-dataBars"
}
}

alt text
alt text

  • Result:

alt text
alt text

Read more on JSON formatting:

SPFx Webparts

In SPFx web parts, you can reuse the classes by using the className attribute. For example, to apply a border to a field, you can use the sp-field-borderAllDashed class:

html
<div className={`sp-field-dataBars sp-field-borderAllDashed`}>

Conclusion

I hope you find this collection of reusable CSS classes helpful. If you have any questions or suggestions, please leave a comment below. 🙏

Found this useful? Follow me on LinkedIn to see my new posts.
Follow on LinkedIn

Tags

SharePointCSSStylesSPFxJSON formatting

Share

Previous Article
Beautiful Power BI Backgrounds
Denis Molodtsov

Denis Molodtsov

Microsoft 365 Architect

Microsoft Most Valuable Professional (MVP)

Related Posts

SharePoint HTML pages, part 3, can they replace modern pages and web parts?
SharePoint HTML pages, part 3, can they replace modern pages and web parts?
November 01, 2026
11 min

Quick Links

AboutAll PostsRSS

Social Media