SharePoint Online Modern communication site pages support section layout, named Full-Width column. It helps to span the section without any horizontal margin or padding.
- Add Full-width Section.
- Add Full-width support to SPFx Control.
- Add SPFx Control to Full-width Section.
Users can choose from a number of different section layouts such as,
- one columns
- two columns
- three columns
- one-third left column
- one-third right column
Full-Width Section Requirement
When we build a regular SPFx control, it doesn’t expand beyond a certain width due to section layouts which don’t support or allow the full width.
So, let’s get started
Step 1 - Add Full-Width Section
- Full-width section allows layouts to expand to the full width of the page.
- Edit the page
- Click the plus “+” icon parallel to the section layout and select the Full-width section.
Step 2 - Add Full-Width support to SPFx Control
SPFx control doesn’t add the full-width column property by default. But SharePoint Framework allows us to add full-width column attributes into the web part manifest file, i.e., GetEmployeeDataWebPart.menifest.json and adds supportsFullBleed property to true.
- {
- "$schema": "https://dev.office.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
- "id": "c58ad54b-0b32-4087-8b9b-5b28ded5e375",
- "alias": "GetEmployeeDataWebPart",
- "componentType": "WebPart",
- // The "*" signifies that the version should be taken from the package.json
- "version": "*",
- "manifestVersion": 2,
- // If true, the component can only be installed on sites where Custom Script is allowed.
- // Components that allow authors to embed arbitrary script code should set this to true.
- // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
- "requiresCustomScript": false,
- "supportsFullBleed": true,
- "preconfiguredEntries": [{
- "groupId": "5c03119e-3074-46fd-976b-c60198311f70",
- "group": { "default": "Other" },
- "title": { "default": "GetEmployeeData" },
- "description": { "default": "GetEmployeeData description" },
- "officeFabricIconFontName": "Page",
- "properties": {
- "listName": "SPFxList"
- }
- }]
- }
Do the above one line setting. Build the bundle and deploy the solution.
Step 3 - Add SPFx Control to Full Width Section
Browse the site and add a full-width section. The custom SPFx control will be available as per the below screenshot.
Click and add control. You can see that the custom control will take the full horizontal section and doesn’t allow margin or spaces.
NoteAs per today, the full-width column section doesn’t work with workbench and Modern Team Sites.
I hope you have enjoyed and learned something new in this article. Thanks for reading. Stay tuned for the next article.
Wow, superb blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is fantastic, as well as the content!
ReplyDeleteI'm impressed, I must say. Seldom do I encounter a blog that's both equally educative and interesting, and let me tell you, you've hit the nail on the head. The problem is something that not enough people are speaking intelligently about. Now i'm very happy I came across this in my hunt for something concerning this.
ReplyDelete