Skip to content

Commit 9fbffb6

Browse files
thechriskentVesaJuvonen
authored andcommitted
Formatting Updates (SharePoint#2976)
1 parent 2451a26 commit 9fbffb6

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

docs/declarative-customization/column-formatting.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ This example uses an Excel-style conditional expression (`=if`) to apply a class
9999
```JSON
100100
{
101101
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
102-
"debugMode": true,
103102
"elmType": "div",
104103
"attributes": {
105104
"class": "=if(@currentField <= 70,'sp-field-severity--warning', '')"
@@ -129,17 +128,16 @@ The following image shows an example of conditional formatting applied to a text
129128

130129
![Status field with done colored green, blocked colored red, and in review colored orange](../images/sp-columnformatting-conditionaladvanced.png)
131130

132-
You can apply conditional formatting to text or choice fields that might contain a fixed set of values. The following example applies different classes depending on whether the value of the field is Done, In Review, Blocked, or another value. This example applies a CSS class (`sp-field-severity--low, sp-field-severity--good, sp-field-severity--warning, sp-field-severity--blocked`) to the `<div />` based on the field's value. It then outputs a `<span />` element with an `IconName` attribute. This attribute applies another CSS class to that `<span />` that shows an [Office UI Fabric](https://dev.office.com/fabric#/) icon inside that element. Finally, another `<span />` element is output that contains the value inside the field.
131+
You can apply conditional formatting to text or choice fields that might contain a fixed set of values. The following example applies different classes depending on whether the value of the field is Done, In Review, Has Issues, or another value. This example applies a CSS class (`sp-field-severity--low, sp-field-severity--good, sp-field-severity--warning, sp-field-severity--severeWarning, sp-field-severity--blocked`) to the `<div />` based on the field's value. It then outputs a `<span />` element with an `IconName` attribute. This attribute automatically applies another CSS class to that `<span />` that shows an [Office UI Fabric](https://dev.office.com/fabric#/) icon inside that element. Finally, another `<span />` element is output that contains the value inside the field.
133132

134133
This pattern is useful when you want different values to map to different levels of urgency or severity. You can start from this example and edit it to specify your own field values and the styles and icons that should map to those values.
135134

136135
```JSON
137136
{
138137
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
139-
"debugMode": true,
140138
"elmType": "div",
141139
"attributes": {
142-
"class": "=if(@currentField == 'Done', 'sp-field-severity--good', if(@currentField == 'In progress', 'sp-field-severity--low' ,if(@currentField == 'In review','sp-field-severity--warning', if(@currentField == 'Blocked','sp-field-severity--blocked', ''))"
140+
"class": "=if(@currentField == 'Done', 'sp-field-severity--good', if(@currentField == 'In progress', 'sp-field-severity--low', if(@currentField == 'In review', 'sp-field-severity--warning', if(@currentField == 'Has issues', 'sp-field-severity--severeWarning', 'sp-field-severity--blocked')))) + ' ms-fontColor-neutralSecondary'"
143141
},
144142
"children": [
145143
{
@@ -149,7 +147,7 @@ This pattern is useful when you want different values to map to different levels
149147
"padding": "0 4px"
150148
},
151149
"attributes": {
152-
"iconName": "=if(@currentField == 'Done','CheckMark', if(@currentField == 'In progress', 'Forward', if(@currentField == 'In review', 'Error', if(@currentField == 'Has issues','Warning','')"
150+
"iconName": "=if(@currentField == 'Done', 'CheckMark', if(@currentField == 'In progress', 'Forward', if(@currentField == 'In review', 'Error', if(@currentField == 'Has issues', 'Warning', 'ErrorBadge'))))"
153151
}
154152
},
155153
{
@@ -182,7 +180,7 @@ This example colors the current field red when the value inside an item's DueDat
182180
"debugMode": true,
183181
"txtContent": "@currentField",
184182
"style": {
185-
"color": "=if([$DueDate] <= @now, '#ff0000', ''"
183+
"color": "=if([$DueDate] <= @now, '#ff0000', '')"
186184
}
187185
}
188186
```
@@ -345,7 +343,7 @@ This example applies `background-color` and `border-top` styles to create a data
345343
"class": "sp-field-dataBars"
346344
},
347345
"style": {
348-
"width": "=if(@currentField > 95, '100%', toString(@currentField * 100 / 95) + '%'"
346+
"width": "=if(@currentField > 95, '100%', toString(@currentField * 100 / 95) + '%')"
349347
}
350348
}
351349
```
@@ -505,9 +503,10 @@ You can use the following predefined classes for several common scenarios.
505503
| sp-field-trending--down |![Red arrow with number 100](../images/sp-columnformatting-trendingdown.png) |
506504
| sp-field-quickActions |![Name with mail icon](../images/sp-columnformatting-quickaction.png) |
507505

508-
> Note - The icons shown above for the `sp-field-severity` classes are **NOT** part of the class. Only the background color is included. Icons can be added by using the `iconName` attribute.
506+
> [!NOTE]
507+
> The icons shown above for the `sp-field-severity` classes are **NOT** part of the class. Only the background color is included. Icons can be added by using the `iconName` attribute.
509508
510-
In addition to the classes listed above, the classes (such as the theme color, typography, grid system, etc.) defined by the Office UI Fabric can be used. For details, see the [Fabric website](https://dev.office.com/fabric#/styles/icons).
509+
In addition to the classes listed above, the classes (such as the theme color, typography, grid system, etc.) defined by the Office UI Fabric can be used. For details, see the [Fabric website](https://dev.office.com/fabric#/styles/colors).
511510

512511
### Predefined icons
513512

@@ -557,7 +556,7 @@ Any other value will result in an error.
557556

558557
`Button` elements can be used to launch a specific action on the parent item. Every `button` element has a requred property, `customRowAction`, that specifies an `action` that's taken when the button is clicked. This action must be one of the following values:
559558

560-
- defaultClick: buttons with this action will do the same thing as clicking the list item in an uncustomized view. Below is an example of a button that, when clicked, simulates a click on the item, which results in the details pane being opened.
559+
- **defaultClick**: buttons with this action will do the same thing as clicking the list item in an uncustomized view. Below is an example of a button that, when clicked, simulates a click on the item, which results in the details pane being opened.
561560

562561
```JSON
563562
{
@@ -570,7 +569,7 @@ Any other value will result in an error.
570569
}
571570

572571
```
573-
- share: Clicking the button will open the sharing dialog. Below is an example of this type of button.
572+
- **share**: Clicking the button will open the sharing dialog. Below is an example of this type of button.
574573

575574
```JSON
576575
{
@@ -583,9 +582,9 @@ Any other value will result in an error.
583582
}
584583

585584
```
586-
- delete: Clicking the button will open the delete confirmation dialog.
587-
- editProps: Clicking the button will open the item properties page in edit mode.
588-
- executeFlow: Clicking the button will launch the specified Flow, specified by ID inside the `actionParams` attribute. For an example of this, see the [Create a button to launch a Flow](https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#create-a-button-to-launch-a-flow) section in this document.
585+
- **delete**: Clicking the button will open the delete confirmation dialog.
586+
- **editProps**: Clicking the button will open the item properties page in edit mode.
587+
- **executeFlow**: Clicking the button will launch the specified Flow, specified by ID inside the `actionParams` attribute. For an example of this, see the [Create a button to launch a Flow](https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#create-a-button-to-launch-a-flow) section in this document.
589588

590589
### txtContent
591590

@@ -638,6 +637,7 @@ An optional property that specifies style attributes to apply to the element spe
638637
'rotation-point'
639638

640639
'opacity'
640+
'cursor'
641641

642642
'height'
643643
'max-height'
@@ -646,7 +646,15 @@ An optional property that specifies style attributes to apply to the element spe
646646
'min-width'
647647
'width'
648648

649+
'flex-grow'
650+
'flex-shrink'
651+
'flex-flow'
652+
'flex-direction'
653+
'flex-wrap'
654+
'flex'
655+
'justify-content'
649656
'align-items'
657+
650658
'box-align'
651659
'box-direction'
652660
'box-flex'

0 commit comments

Comments
 (0)