SharePointVault ~/gotchas/lists ⌕ Search 404 pages, error messages, scripts…Ctrl K ★ Star
M↓ README.mdM↓ view-formatting-drops-css-gradients.md
sharepoint-vault›gotchas›lists›view-formatting-drops-css-gradients.mdhistoryedit on GitHub
● GOTCHAlists· 1 min read

View formatting drops CSS gradients — use a solid background-color

applies to: SharePoint Online (column and view formatting)reviewed: 2026-09-24#lists#view-formatting#column-formatting#css

List formatting accepts a fixed allowlist of style properties. background is not on it, and a linear-gradient(…) in background-image did not survive in our tests either — so an element whose legibility depends on a gradient, such as a white initial on a gradient avatar, renders as white on white. Give every coloured element a solid background-color.

Formátování seznamů přijímá pevný seznam povolených stylových vlastností. background na něm není a linear-gradient(…) v background-image v našich testech také nepřežil – prvek, jehož čitelnost stojí na přechodu, třeba bílá iniciála na avataru s přechodem, se proto vykreslí bíle na bílém. Každému barevnému prvku dej plnou background-color.

Symptom

A gallery or row formatter shows people as round avatars with a white initial on a two-colour gradient. In the list, the circle is transparent and the white letter sits on a white row — invisible.

Cause

The style object of a formatter accepts only a documented list of style attributes. background-color and background-image are on it; the background shorthand is not. A gradient did not render through either property in our tests, so the element was left without any background.

Fix

"style": {
  "background-color": "=if([$Role] == 'Lead', '#0f6cbd', '#107c10')",
  "color": "#ffffff"
}

Let colour carry meaning through a solid background-color, computed per item if you like, and never let legibility depend on a decoration.

Notes

Was this helpful?ask or add your experience on GitHub →
Saved you an hour? A star on GitHub helps other SharePoint people find the vault.★ Star on GitHub
last reviewed: 2026-09-24last updated: 2026-09-24historyedit on GitHubview source