SlideShare a Scribd company logo
Shadow DOM, CSS
and styling hooks in
LWC: what you need
to know
Alba Rivas, Lead Developer Advocate, Salesforce
11 February 2021
Alba Rivas
Lead Developer Advocate
arivas@salesforce.com, @AlbaSFDC
Forward-Looking Statement
Salesforce Confidential. Not for external distribution.
Presentation Name | Slide #
Statement under the Private Securities Litigation Reform Act of 1995:
This presentation contains forward-looking statements about the company’s financial and operating results, which may include expected GAAP and non-GAAP financial and other
operating and non-operating results, including revenue, net income, diluted earnings per share, operating cash flow growth, operating margin improvement, expected revenue
growth, expected current remaining performance obligation growth, expected tax rates, the one-time accounting non-cash charge that was incurred in connection with the
Salesforce.org combination; stock-based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth and sustainability goals. The
achievement or success of the matters covered by such forward-looking statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any
of the assumptions prove incorrect, the company’s results could differ materially from the results expressed or implied by the forward-looking statements we make.
The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of geopolitical
events; the impact of foreign currency exchange rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be
the leading provider of enterprise cloud computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our
sales cycles; the competitive nature of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from
significant growth in our customer base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid
unanticipated downtime and prevent, detect and remediate potential security breaches; the expenses associated with new data centers and third-party infrastructure providers;
additional data center capacity; real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our
services beyond the CRM market; our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights;
the performance and fair value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic
partnerships, joint ventures and investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that
may affect the publicly traded companies within the company's strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired
businesses and technologies, including delays related to the integration of Tableau due to regulatory review by the United Kingdom Competition and Markets Authority; our ability to
continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our reliance on
third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of evolving domestic
and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those addressing data privacy,
cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the potential availability of
additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate; the impact of expensing
stock options and other equity awards; the sufficiency of our capital resources; factors related to our outstanding debt, revolving credit facility, term loan and loan associated with 50
Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving us; and the impact of climate change.
Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes
with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s
website at www.salesforce.com/investor.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.
Agenda
● Shadow DOM
● LWC Shadow DOM implementations
● CSS & LWC
● CSS Custom Properties
● Styling Hooks
● Ways to import and share CSS
● SLDS Validator
Lightning Web Components
Native Shadow DOM
Shadow DOM
#shadow-root
|_h1
|_span
html
|_head
|_title
|_style
|_body
|_h1
|_div
|_span
|_p
|_a
html
|_head
|_title
|_style
|_body
|_h1
|_div →
|_span
|_p
|_a
shadow
boundary
shadow
host
const el = document.querySelector('div');
const shadowRoot = el.attachShadow({mode: 'open'});
shadowRoot.innerHTML = "<h1>I belong to <span>Shadow DOM</span></h1>";
html
|_head
|_title
|_style
|_body
|_h1
|_div
|_h1
|_span
|_span
|_p
|_a
Flattened DOM
Light DOM
Shadow DOM
Native Shadow DOM
Shadow DOM
Encapsulates:
● Markup: shadow DOM elements are queried differently,
and only possible if the shadow tree is ‘open’
● Behaviour: events need to be configured as composed
and bubbles to escape the shadow boundary
○ All UA-dispatched UI events are composed
(click/touch/mouseover/copy/paste, etc.).
● CSS: CSS cascading doesn’t affect inner shadow DOM
elements - inherited CSS properties do. More later!
el.shadowRoot.querySelector('h1')
const selectEvent = new
CustomEvent('contactselect', {
bubbles: true,
composed: true
});
Not available if closed mode
Shadow DOM in Vanilla Web
Components
class cascadingAndInheritance extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
}
connectedCallback() {
console.log(this.shadowRoot.querySelector('h1'))
}
}
Elements of vanilla Web Components are enclosed in a native Shadow DOM Tree
Native Shadow DOM (Vanilla Web Components)
Shadow DOM in LWC
Elements of LWCs are enclosed in a Native or Synthetic Shadow DOM Tree
class MyLightningWebComponent extends LightningElement {
connectedCallback() {
console.log(this.template.querySelector('h1'))
}
}
LWC OSS (Synthetic)
Shadow DOM in LWC
LWC on platform (Synthetic) - backwards compatibility
LWC OSS (Native) - default
Cascading vs Inheritance
CSS
Cascading → combining CSS rules in different stylesheets that are applied to an
element
Inheritance → some CSS property values set on parent elements are inherited by their
child elements, if no cascaded value found - only some (color, font-...)
Property value =
Property initial value
Cascaded
value?
Inherited
property?
Property value =
Property value on
parent element
Property value =
Cascaded value
YES
NO
YES
NO
Cascading vs Inheritance
CSS
h1 {
color: red;
}
h1 {
color: blue;
}
div {
color: green;
}
span {
color: orange;
}
<h1>Salesforce Mascots Stories</h1>
<div>
<p>Astro and Codey are <span>good friends!</span></p>
</div>
Cascaded value
Inherited value Cascaded Value
Prevent inheritance from affecting your styles
Either explicitly set the color, or revert them to their original state
CSS & LWC OSS - Native
<template>
<h1>I belong to parent component Shadow DOM</h1>
<div><my-cascading-and-inheritance></my-cascading-and-inheritance></div>
</template>
h1 {
color: red;
}
h1 {
color: blue;
}
div {
color: green;
}
span {
color: orange;
}
<template>
<h1>I belong to child component Shadow DOM</h1>
<p>Astro and Codey are <span>good friends!</span></p>
</template>
cascadingAndInheritance.html
cascadingAndInheritanceContainer.html
cascadingAndInheritanceContainer.css
shadow boundary
CSS & LWC / LWC OSS - Synthetic
<template>
<h1>I belong to parent component Shadow DOM</h1>
<div><c-cascading-and-inheritance></c-cascading-and-inheritance></div>
</template>
h1 {
color: red;
}
h1 {
color: blue;
}
div {
color: green;
}
span {
color: orange;
}
<template>
<h1>I belong to child component Shadow DOM</h1>
<p>Astro and Codey are <span>good friends!</span></p>
</template>
cascadingAndInheritance.html
cascadingAndInheritanceContainer.html cascadingAndInheritanceContainer.css
SLDS Styles or
styles loaded
via loadStyle
not scoped!!
CSS Custom Properties
(CSS Variables)
Entities to allow reusing CSS property values
● Defined on a scope, and accessed with var
● Case sensitive
● Can penetrate Shadow DOM
Used in LWC for
● Styling Hooks
● Aura Design Tokens
● SLDS Design Tokens
Need to be allowed explicitly in LWC OSS
Set a Custom Property
Get a Custom Property
Setting CSS Custom Properties from JS
Styling Hooks (beta)
CSS Custom Properties defined in base components and SLDS blueprints to allow
customization
Looking for feedback → sfdc.co/stylinghooks
Global Styling Hooks coming soon!
Styling Hooks (beta)
Best practice: Don’t override standard styles. Use Styling hooks.
Aura Design Tokens
Use CSS Variables to access Aura design tokens both in Aura and LWC
Reuse CSS across Aura and LWC!
.THIS h1 {
color : token(myTitleColor);
}
h1 {
color: var(--c-myTitleColor);
}
<aura:tokens>
<aura:token name="myTitleColor" value="blue"/>
</aura:tokens>
Aura LWC
SLDS Design Tokens
lightningdesignsystem.com/design-tokens
Importing CSS
Single File Multiple Files
Static Resource
Styles scoped globally (same as SLDS) - when using synthetic shadow
Importing CSS
Create a LWC with just the CSS file
Import using the syntax @import <namespace>/<componentname>
Styles scoped to the component
Best practice: create a shared CSS Module with all your CSS Custom Properties
CSS modules
importCSSsharedModule.css
Cascading Order
If different rules for the same selector, the following will have preference, in order:
● Inline styles
● CSS defined in component CSS file (scoped)
● CSS imported using @import (scoped)
● CSS imported with loadStyle (global) - only apply if synthetic
Sharing Tokens and Properties
Create Aura Design Tokens to reuse config across Aura and LWC
Create a Shared CSS Module with all CSS Custom Properties
Global Styling Hooks coming soon!
SLDS Validator
VSCode plugin
Part of Salesforce Extension pack
Smart Suggestions
Recommended tokens and utility
classes, in CSS and HTML
Save Time
Syntax highlighting and code
completion
Summary
● Understand Shadow DOM and the different implementations in LWC
● Master CSS: cascading, inherited and custom properties
● Styling hooks, Aura design tokens and SLDS design token
● Know and choose the best ways to import and share your CSS
● SLDS Validator is your friend!
github.com/albarivas/shadow-dom
github.com/albarivas/shadow-dom-oss
Thank You!
Ad

More Related Content

What's hot (20)

Lightning Web Component in Salesforce
Lightning Web Component in SalesforceLightning Web Component in Salesforce
Lightning Web Component in Salesforce
Jitendra Zaa
 
Salesforce Lightning Web Components Overview
Salesforce Lightning Web Components OverviewSalesforce Lightning Web Components Overview
Salesforce Lightning Web Components Overview
Nagarjuna Kaipu
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
Salesforce Developers
 
Data model in salesforce
Data model in salesforceData model in salesforce
Data model in salesforce
Chamil Madusanka
 
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Episode 8  - Path To Code - Integrate Salesforce with external system using R...Episode 8  - Path To Code - Integrate Salesforce with external system using R...
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Jitendra Zaa
 
Introduction to apex code
Introduction to apex codeIntroduction to apex code
Introduction to apex code
EdwinOstos
 
Introduction to Lightning Web Component
Introduction to Lightning Web Component Introduction to Lightning Web Component
Introduction to Lightning Web Component
SmritiSharan1
 
Single Sign-On and User Management With Salesforce Identity
Single Sign-On and User Management With Salesforce IdentitySingle Sign-On and User Management With Salesforce Identity
Single Sign-On and User Management With Salesforce Identity
Salesforce Developers
 
Introduction to Web Standards
Introduction to Web StandardsIntroduction to Web Standards
Introduction to Web Standards
Jussi Pohjolainen
 
Salesforce asynchronous apex
Salesforce asynchronous apexSalesforce asynchronous apex
Salesforce asynchronous apex
Badan Singh Pundeer
 
Javascript Execution Context Flow
Javascript Execution Context FlowJavascript Execution Context Flow
Javascript Execution Context Flow
kang taehun
 
Introduction to Apex Triggers
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex Triggers
Salesforce Developers
 
Deep Dive into Apex Triggers
Deep Dive into Apex TriggersDeep Dive into Apex Triggers
Deep Dive into Apex Triggers
Salesforce Developers
 
Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforce
Mark Adcock
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Single Sign-On and User Provisioning with Salesforce Identity
Single Sign-On and User Provisioning with Salesforce IdentitySingle Sign-On and User Provisioning with Salesforce Identity
Single Sign-On and User Provisioning with Salesforce Identity
Salesforce Developers
 
Apex Testing Best Practices
Apex Testing Best PracticesApex Testing Best Practices
Apex Testing Best Practices
Salesforce Developers
 
Introducing: The Lightning Experience
Introducing: The Lightning ExperienceIntroducing: The Lightning Experience
Introducing: The Lightning Experience
Dreamforce
 
Api Testing
Api TestingApi Testing
Api Testing
Vishwanath KC
 
Lightning Web Component - LWC
Lightning Web Component - LWCLightning Web Component - LWC
Lightning Web Component - LWC
Thierry TROUIN ☁
 
Lightning Web Component in Salesforce
Lightning Web Component in SalesforceLightning Web Component in Salesforce
Lightning Web Component in Salesforce
Jitendra Zaa
 
Salesforce Lightning Web Components Overview
Salesforce Lightning Web Components OverviewSalesforce Lightning Web Components Overview
Salesforce Lightning Web Components Overview
Nagarjuna Kaipu
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
Salesforce Developers
 
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Episode 8  - Path To Code - Integrate Salesforce with external system using R...Episode 8  - Path To Code - Integrate Salesforce with external system using R...
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Jitendra Zaa
 
Introduction to apex code
Introduction to apex codeIntroduction to apex code
Introduction to apex code
EdwinOstos
 
Introduction to Lightning Web Component
Introduction to Lightning Web Component Introduction to Lightning Web Component
Introduction to Lightning Web Component
SmritiSharan1
 
Single Sign-On and User Management With Salesforce Identity
Single Sign-On and User Management With Salesforce IdentitySingle Sign-On and User Management With Salesforce Identity
Single Sign-On and User Management With Salesforce Identity
Salesforce Developers
 
Introduction to Web Standards
Introduction to Web StandardsIntroduction to Web Standards
Introduction to Web Standards
Jussi Pohjolainen
 
Javascript Execution Context Flow
Javascript Execution Context FlowJavascript Execution Context Flow
Javascript Execution Context Flow
kang taehun
 
Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforce
Mark Adcock
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Single Sign-On and User Provisioning with Salesforce Identity
Single Sign-On and User Provisioning with Salesforce IdentitySingle Sign-On and User Provisioning with Salesforce Identity
Single Sign-On and User Provisioning with Salesforce Identity
Salesforce Developers
 
Introducing: The Lightning Experience
Introducing: The Lightning ExperienceIntroducing: The Lightning Experience
Introducing: The Lightning Experience
Dreamforce
 

Similar to Shadow DOM, CSS and Styling Hooks in LWC what you need to know (20)

Winter '22 highlights
Winter '22 highlightsWinter '22 highlights
Winter '22 highlights
AtaullahKhan31
 
Lightning Components 101: An Apex Developer's Guide
Lightning Components 101: An Apex Developer's GuideLightning Components 101: An Apex Developer's Guide
Lightning Components 101: An Apex Developer's Guide
Adam Olshansky
 
Salesforce Backup, Restore & Archiving- Adam Best, Senior Program Architect
Salesforce Backup, Restore & Archiving- Adam Best, Senior Program ArchitectSalesforce Backup, Restore & Archiving- Adam Best, Senior Program Architect
Salesforce Backup, Restore & Archiving- Adam Best, Senior Program Architect
gemziebeth
 
Experience cloud for salesforce user group wellington may 2021
Experience cloud for salesforce user group wellington may 2021Experience cloud for salesforce user group wellington may 2021
Experience cloud for salesforce user group wellington may 2021
Anna Loughnan Colquhoun
 
Dreamforce 22 Unleash Powerful Data Transforms in Apex with DataWeave
Dreamforce 22 Unleash Powerful Data Transforms in Apex with DataWeaveDreamforce 22 Unleash Powerful Data Transforms in Apex with DataWeave
Dreamforce 22 Unleash Powerful Data Transforms in Apex with DataWeave
DanielBallinger3
 
Salesforce Learning Journey - Partner Guide to Credentials.pdf
Salesforce Learning Journey - Partner Guide to Credentials.pdfSalesforce Learning Journey - Partner Guide to Credentials.pdf
Salesforce Learning Journey - Partner Guide to Credentials.pdf
ssuser72de80
 
Summer 23 LWC Updates + Slack Apps.pptx
Summer 23 LWC Updates + Slack Apps.pptxSummer 23 LWC Updates + Slack Apps.pptx
Summer 23 LWC Updates + Slack Apps.pptx
Kishore B T
 
Austin Developers - New Lighting Web Component Features & #TDX22 Updates
Austin Developers - New Lighting Web Component Features & #TDX22 UpdatesAustin Developers - New Lighting Web Component Features & #TDX22 Updates
Austin Developers - New Lighting Web Component Features & #TDX22 Updates
NadinaLisbon1
 
Using Styling Hooks to Customize Your LWC
Using Styling Hooks to Customize Your LWCUsing Styling Hooks to Customize Your LWC
Using Styling Hooks to Customize Your LWC
Sudipta Deb ☁
 
#ImpactSalesforceSaturday: Prepare for Salesforce Certified Heroku Architectu...
#ImpactSalesforceSaturday: Prepare for Salesforce Certified Heroku Architectu...#ImpactSalesforceSaturday: Prepare for Salesforce Certified Heroku Architectu...
#ImpactSalesforceSaturday: Prepare for Salesforce Certified Heroku Architectu...
New Delhi Salesforce Developer Group
 
TDX Global Gathering - Wellington UG
TDX Global Gathering - Wellington UGTDX Global Gathering - Wellington UG
TDX Global Gathering - Wellington UG
Stephan Chandler-Garcia
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
Salesforce Developers
 
Kitchener Developer Group's session on "All about events"
Kitchener Developer Group's session on "All about events"Kitchener Developer Group's session on "All about events"
Kitchener Developer Group's session on "All about events"
Sudipta Deb ☁
 
Alba Rivas - Building Slack Applications with Bolt.js.pdf
Alba Rivas - Building Slack Applications with Bolt.js.pdfAlba Rivas - Building Slack Applications with Bolt.js.pdf
Alba Rivas - Building Slack Applications with Bolt.js.pdf
MarkPawlikowski2
 
Successfully retrieving metadata from salesforce org using packages
Successfully retrieving metadata from salesforce org using packagesSuccessfully retrieving metadata from salesforce org using packages
Successfully retrieving metadata from salesforce org using packages
Mohith Shrivastava
 
Bangkok Admin Group TrailheaDX 2020 Global Gathering v2
Bangkok Admin Group TrailheaDX 2020 Global Gathering v2Bangkok Admin Group TrailheaDX 2020 Global Gathering v2
Bangkok Admin Group TrailheaDX 2020 Global Gathering v2
Jihun Jung
 
TrailheadX Presentation - 2020 Cluj
TrailheadX Presentation -  2020 ClujTrailheadX Presentation -  2020 Cluj
TrailheadX Presentation - 2020 Cluj
Arpad Komaromi
 
Intro to Tableau - SL Dev Group.pdf
Intro to Tableau - SL Dev Group.pdfIntro to Tableau - SL Dev Group.pdf
Intro to Tableau - SL Dev Group.pdf
Salesforce.com Developer Community
 
#DF19 - Panel: Design Justification & Objection Handling for Architects
#DF19 - Panel: Design Justification & Objection Handling for Architects#DF19 - Panel: Design Justification & Objection Handling for Architects
#DF19 - Panel: Design Justification & Objection Handling for Architects
Kerry Townsend
 
Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...
Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...
Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...
Anna Loughnan Colquhoun
 
Lightning Components 101: An Apex Developer's Guide
Lightning Components 101: An Apex Developer's GuideLightning Components 101: An Apex Developer's Guide
Lightning Components 101: An Apex Developer's Guide
Adam Olshansky
 
Salesforce Backup, Restore & Archiving- Adam Best, Senior Program Architect
Salesforce Backup, Restore & Archiving- Adam Best, Senior Program ArchitectSalesforce Backup, Restore & Archiving- Adam Best, Senior Program Architect
Salesforce Backup, Restore & Archiving- Adam Best, Senior Program Architect
gemziebeth
 
Experience cloud for salesforce user group wellington may 2021
Experience cloud for salesforce user group wellington may 2021Experience cloud for salesforce user group wellington may 2021
Experience cloud for salesforce user group wellington may 2021
Anna Loughnan Colquhoun
 
Dreamforce 22 Unleash Powerful Data Transforms in Apex with DataWeave
Dreamforce 22 Unleash Powerful Data Transforms in Apex with DataWeaveDreamforce 22 Unleash Powerful Data Transforms in Apex with DataWeave
Dreamforce 22 Unleash Powerful Data Transforms in Apex with DataWeave
DanielBallinger3
 
Salesforce Learning Journey - Partner Guide to Credentials.pdf
Salesforce Learning Journey - Partner Guide to Credentials.pdfSalesforce Learning Journey - Partner Guide to Credentials.pdf
Salesforce Learning Journey - Partner Guide to Credentials.pdf
ssuser72de80
 
Summer 23 LWC Updates + Slack Apps.pptx
Summer 23 LWC Updates + Slack Apps.pptxSummer 23 LWC Updates + Slack Apps.pptx
Summer 23 LWC Updates + Slack Apps.pptx
Kishore B T
 
Austin Developers - New Lighting Web Component Features & #TDX22 Updates
Austin Developers - New Lighting Web Component Features & #TDX22 UpdatesAustin Developers - New Lighting Web Component Features & #TDX22 Updates
Austin Developers - New Lighting Web Component Features & #TDX22 Updates
NadinaLisbon1
 
Using Styling Hooks to Customize Your LWC
Using Styling Hooks to Customize Your LWCUsing Styling Hooks to Customize Your LWC
Using Styling Hooks to Customize Your LWC
Sudipta Deb ☁
 
#ImpactSalesforceSaturday: Prepare for Salesforce Certified Heroku Architectu...
#ImpactSalesforceSaturday: Prepare for Salesforce Certified Heroku Architectu...#ImpactSalesforceSaturday: Prepare for Salesforce Certified Heroku Architectu...
#ImpactSalesforceSaturday: Prepare for Salesforce Certified Heroku Architectu...
New Delhi Salesforce Developer Group
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
Salesforce Developers
 
Kitchener Developer Group's session on "All about events"
Kitchener Developer Group's session on "All about events"Kitchener Developer Group's session on "All about events"
Kitchener Developer Group's session on "All about events"
Sudipta Deb ☁
 
Alba Rivas - Building Slack Applications with Bolt.js.pdf
Alba Rivas - Building Slack Applications with Bolt.js.pdfAlba Rivas - Building Slack Applications with Bolt.js.pdf
Alba Rivas - Building Slack Applications with Bolt.js.pdf
MarkPawlikowski2
 
Successfully retrieving metadata from salesforce org using packages
Successfully retrieving metadata from salesforce org using packagesSuccessfully retrieving metadata from salesforce org using packages
Successfully retrieving metadata from salesforce org using packages
Mohith Shrivastava
 
Bangkok Admin Group TrailheaDX 2020 Global Gathering v2
Bangkok Admin Group TrailheaDX 2020 Global Gathering v2Bangkok Admin Group TrailheaDX 2020 Global Gathering v2
Bangkok Admin Group TrailheaDX 2020 Global Gathering v2
Jihun Jung
 
TrailheadX Presentation - 2020 Cluj
TrailheadX Presentation -  2020 ClujTrailheadX Presentation -  2020 Cluj
TrailheadX Presentation - 2020 Cluj
Arpad Komaromi
 
#DF19 - Panel: Design Justification & Objection Handling for Architects
#DF19 - Panel: Design Justification & Objection Handling for Architects#DF19 - Panel: Design Justification & Objection Handling for Architects
#DF19 - Panel: Design Justification & Objection Handling for Architects
Kerry Townsend
 
Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...
Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...
Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...
Anna Loughnan Colquhoun
 
Ad

More from Sudipta Deb ☁ (14)

Kitchener Canada Developer Group Event: From Admin to Certified Technical Arc...
Kitchener Canada Developer Group Event: From Admin to Certified Technical Arc...Kitchener Canada Developer Group Event: From Admin to Certified Technical Arc...
Kitchener Canada Developer Group Event: From Admin to Certified Technical Arc...
Sudipta Deb ☁
 
DevOps 101
DevOps 101DevOps 101
DevOps 101
Sudipta Deb ☁
 
Learn how Source Tracking can keep metadata changes in sync between your loca...
Learn how Source Tracking can keep metadata changes in sync between your loca...Learn how Source Tracking can keep metadata changes in sync between your loca...
Learn how Source Tracking can keep metadata changes in sync between your loca...
Sudipta Deb ☁
 
Orchestrate all of your salesforce automation with the trigger actions framework
Orchestrate all of your salesforce automation with the trigger actions frameworkOrchestrate all of your salesforce automation with the trigger actions framework
Orchestrate all of your salesforce automation with the trigger actions framework
Sudipta Deb ☁
 
Let's Learn About Heroku and How to Integrate with Salesforce
Let's Learn About Heroku and How to Integrate with SalesforceLet's Learn About Heroku and How to Integrate with Salesforce
Let's Learn About Heroku and How to Integrate with Salesforce
Sudipta Deb ☁
 
Algorithms design and analysis, part 1
Algorithms  design and analysis, part 1Algorithms  design and analysis, part 1
Algorithms design and analysis, part 1
Sudipta Deb ☁
 
Functional programming principles in scala
Functional programming principles in scalaFunctional programming principles in scala
Functional programming principles in scala
Sudipta Deb ☁
 
Principles of reactive programming
Principles of reactive programmingPrinciples of reactive programming
Principles of reactive programming
Sudipta Deb ☁
 
Automate the development lifecycle with cumulus ci on april 9th, 2020
Automate the development lifecycle with cumulus ci on april 9th, 2020Automate the development lifecycle with cumulus ci on april 9th, 2020
Automate the development lifecycle with cumulus ci on april 9th, 2020
Sudipta Deb ☁
 
Dreamforce Global Gathering
Dreamforce Global GatheringDreamforce Global Gathering
Dreamforce Global Gathering
Sudipta Deb ☁
 
Kitchener Salesforce Developer Group Event - Introduction to dev ops with Sal...
Kitchener Salesforce Developer Group Event - Introduction to dev ops with Sal...Kitchener Salesforce Developer Group Event - Introduction to dev ops with Sal...
Kitchener Salesforce Developer Group Event - Introduction to dev ops with Sal...
Sudipta Deb ☁
 
Introduction to lightning web component
Introduction to lightning web component Introduction to lightning web component
Introduction to lightning web component
Sudipta Deb ☁
 
Kitchener CA Developer Group Presents Everything you need to know about Einst...
Kitchener CA Developer Group Presents Everything you need to know about Einst...Kitchener CA Developer Group Presents Everything you need to know about Einst...
Kitchener CA Developer Group Presents Everything you need to know about Einst...
Sudipta Deb ☁
 
Building lightning apps by Daniel Peter
Building lightning apps by Daniel PeterBuilding lightning apps by Daniel Peter
Building lightning apps by Daniel Peter
Sudipta Deb ☁
 
Kitchener Canada Developer Group Event: From Admin to Certified Technical Arc...
Kitchener Canada Developer Group Event: From Admin to Certified Technical Arc...Kitchener Canada Developer Group Event: From Admin to Certified Technical Arc...
Kitchener Canada Developer Group Event: From Admin to Certified Technical Arc...
Sudipta Deb ☁
 
Learn how Source Tracking can keep metadata changes in sync between your loca...
Learn how Source Tracking can keep metadata changes in sync between your loca...Learn how Source Tracking can keep metadata changes in sync between your loca...
Learn how Source Tracking can keep metadata changes in sync between your loca...
Sudipta Deb ☁
 
Orchestrate all of your salesforce automation with the trigger actions framework
Orchestrate all of your salesforce automation with the trigger actions frameworkOrchestrate all of your salesforce automation with the trigger actions framework
Orchestrate all of your salesforce automation with the trigger actions framework
Sudipta Deb ☁
 
Let's Learn About Heroku and How to Integrate with Salesforce
Let's Learn About Heroku and How to Integrate with SalesforceLet's Learn About Heroku and How to Integrate with Salesforce
Let's Learn About Heroku and How to Integrate with Salesforce
Sudipta Deb ☁
 
Algorithms design and analysis, part 1
Algorithms  design and analysis, part 1Algorithms  design and analysis, part 1
Algorithms design and analysis, part 1
Sudipta Deb ☁
 
Functional programming principles in scala
Functional programming principles in scalaFunctional programming principles in scala
Functional programming principles in scala
Sudipta Deb ☁
 
Principles of reactive programming
Principles of reactive programmingPrinciples of reactive programming
Principles of reactive programming
Sudipta Deb ☁
 
Automate the development lifecycle with cumulus ci on april 9th, 2020
Automate the development lifecycle with cumulus ci on april 9th, 2020Automate the development lifecycle with cumulus ci on april 9th, 2020
Automate the development lifecycle with cumulus ci on april 9th, 2020
Sudipta Deb ☁
 
Dreamforce Global Gathering
Dreamforce Global GatheringDreamforce Global Gathering
Dreamforce Global Gathering
Sudipta Deb ☁
 
Kitchener Salesforce Developer Group Event - Introduction to dev ops with Sal...
Kitchener Salesforce Developer Group Event - Introduction to dev ops with Sal...Kitchener Salesforce Developer Group Event - Introduction to dev ops with Sal...
Kitchener Salesforce Developer Group Event - Introduction to dev ops with Sal...
Sudipta Deb ☁
 
Introduction to lightning web component
Introduction to lightning web component Introduction to lightning web component
Introduction to lightning web component
Sudipta Deb ☁
 
Kitchener CA Developer Group Presents Everything you need to know about Einst...
Kitchener CA Developer Group Presents Everything you need to know about Einst...Kitchener CA Developer Group Presents Everything you need to know about Einst...
Kitchener CA Developer Group Presents Everything you need to know about Einst...
Sudipta Deb ☁
 
Building lightning apps by Daniel Peter
Building lightning apps by Daniel PeterBuilding lightning apps by Daniel Peter
Building lightning apps by Daniel Peter
Sudipta Deb ☁
 
Ad

Recently uploaded (20)

Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 

Shadow DOM, CSS and Styling Hooks in LWC what you need to know

  • 1. Shadow DOM, CSS and styling hooks in LWC: what you need to know Alba Rivas, Lead Developer Advocate, Salesforce 11 February 2021
  • 3. Forward-Looking Statement Salesforce Confidential. Not for external distribution. Presentation Name | Slide # Statement under the Private Securities Litigation Reform Act of 1995: This presentation contains forward-looking statements about the company’s financial and operating results, which may include expected GAAP and non-GAAP financial and other operating and non-operating results, including revenue, net income, diluted earnings per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected current remaining performance obligation growth, expected tax rates, the one-time accounting non-cash charge that was incurred in connection with the Salesforce.org combination; stock-based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth and sustainability goals. The achievement or success of the matters covered by such forward-looking statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s results could differ materially from the results expressed or implied by the forward-looking statements we make. The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of geopolitical events; the impact of foreign currency exchange rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading provider of enterprise cloud computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the competitive nature of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our customer base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and prevent, detect and remediate potential security breaches; the expenses associated with new data centers and third-party infrastructure providers; additional data center capacity; real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market; our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly traded companies within the company's strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies, including delays related to the integration of Tableau due to regulatory review by the United Kingdom Competition and Markets Authority; our ability to continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our reliance on third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the potential availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our outstanding debt, revolving credit facility, term loan and loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving us; and the impact of climate change. Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s website at www.salesforce.com/investor. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.
  • 4. Agenda ● Shadow DOM ● LWC Shadow DOM implementations ● CSS & LWC ● CSS Custom Properties ● Styling Hooks ● Ways to import and share CSS ● SLDS Validator
  • 6. Native Shadow DOM Shadow DOM #shadow-root |_h1 |_span html |_head |_title |_style |_body |_h1 |_div |_span |_p |_a html |_head |_title |_style |_body |_h1 |_div → |_span |_p |_a shadow boundary shadow host const el = document.querySelector('div'); const shadowRoot = el.attachShadow({mode: 'open'}); shadowRoot.innerHTML = "<h1>I belong to <span>Shadow DOM</span></h1>"; html |_head |_title |_style |_body |_h1 |_div |_h1 |_span |_span |_p |_a Flattened DOM Light DOM Shadow DOM
  • 7. Native Shadow DOM Shadow DOM Encapsulates: ● Markup: shadow DOM elements are queried differently, and only possible if the shadow tree is ‘open’ ● Behaviour: events need to be configured as composed and bubbles to escape the shadow boundary ○ All UA-dispatched UI events are composed (click/touch/mouseover/copy/paste, etc.). ● CSS: CSS cascading doesn’t affect inner shadow DOM elements - inherited CSS properties do. More later! el.shadowRoot.querySelector('h1') const selectEvent = new CustomEvent('contactselect', { bubbles: true, composed: true }); Not available if closed mode
  • 8. Shadow DOM in Vanilla Web Components class cascadingAndInheritance extends HTMLElement { constructor() { super(); this.attachShadow({ mode: "open" }); } connectedCallback() { console.log(this.shadowRoot.querySelector('h1')) } } Elements of vanilla Web Components are enclosed in a native Shadow DOM Tree Native Shadow DOM (Vanilla Web Components)
  • 9. Shadow DOM in LWC Elements of LWCs are enclosed in a Native or Synthetic Shadow DOM Tree class MyLightningWebComponent extends LightningElement { connectedCallback() { console.log(this.template.querySelector('h1')) } }
  • 10. LWC OSS (Synthetic) Shadow DOM in LWC LWC on platform (Synthetic) - backwards compatibility LWC OSS (Native) - default
  • 11. Cascading vs Inheritance CSS Cascading → combining CSS rules in different stylesheets that are applied to an element Inheritance → some CSS property values set on parent elements are inherited by their child elements, if no cascaded value found - only some (color, font-...) Property value = Property initial value Cascaded value? Inherited property? Property value = Property value on parent element Property value = Cascaded value YES NO YES NO
  • 12. Cascading vs Inheritance CSS h1 { color: red; } h1 { color: blue; } div { color: green; } span { color: orange; } <h1>Salesforce Mascots Stories</h1> <div> <p>Astro and Codey are <span>good friends!</span></p> </div> Cascaded value Inherited value Cascaded Value
  • 13. Prevent inheritance from affecting your styles Either explicitly set the color, or revert them to their original state
  • 14. CSS & LWC OSS - Native <template> <h1>I belong to parent component Shadow DOM</h1> <div><my-cascading-and-inheritance></my-cascading-and-inheritance></div> </template> h1 { color: red; } h1 { color: blue; } div { color: green; } span { color: orange; } <template> <h1>I belong to child component Shadow DOM</h1> <p>Astro and Codey are <span>good friends!</span></p> </template> cascadingAndInheritance.html cascadingAndInheritanceContainer.html cascadingAndInheritanceContainer.css shadow boundary
  • 15. CSS & LWC / LWC OSS - Synthetic <template> <h1>I belong to parent component Shadow DOM</h1> <div><c-cascading-and-inheritance></c-cascading-and-inheritance></div> </template> h1 { color: red; } h1 { color: blue; } div { color: green; } span { color: orange; } <template> <h1>I belong to child component Shadow DOM</h1> <p>Astro and Codey are <span>good friends!</span></p> </template> cascadingAndInheritance.html cascadingAndInheritanceContainer.html cascadingAndInheritanceContainer.css SLDS Styles or styles loaded via loadStyle not scoped!!
  • 16. CSS Custom Properties (CSS Variables) Entities to allow reusing CSS property values ● Defined on a scope, and accessed with var ● Case sensitive ● Can penetrate Shadow DOM Used in LWC for ● Styling Hooks ● Aura Design Tokens ● SLDS Design Tokens Need to be allowed explicitly in LWC OSS Set a Custom Property Get a Custom Property
  • 17. Setting CSS Custom Properties from JS
  • 18. Styling Hooks (beta) CSS Custom Properties defined in base components and SLDS blueprints to allow customization Looking for feedback → sfdc.co/stylinghooks Global Styling Hooks coming soon!
  • 19. Styling Hooks (beta) Best practice: Don’t override standard styles. Use Styling hooks.
  • 20. Aura Design Tokens Use CSS Variables to access Aura design tokens both in Aura and LWC Reuse CSS across Aura and LWC! .THIS h1 { color : token(myTitleColor); } h1 { color: var(--c-myTitleColor); } <aura:tokens> <aura:token name="myTitleColor" value="blue"/> </aura:tokens> Aura LWC
  • 22. Importing CSS Single File Multiple Files Static Resource Styles scoped globally (same as SLDS) - when using synthetic shadow
  • 23. Importing CSS Create a LWC with just the CSS file Import using the syntax @import <namespace>/<componentname> Styles scoped to the component Best practice: create a shared CSS Module with all your CSS Custom Properties CSS modules importCSSsharedModule.css
  • 24. Cascading Order If different rules for the same selector, the following will have preference, in order: ● Inline styles ● CSS defined in component CSS file (scoped) ● CSS imported using @import (scoped) ● CSS imported with loadStyle (global) - only apply if synthetic
  • 25. Sharing Tokens and Properties Create Aura Design Tokens to reuse config across Aura and LWC Create a Shared CSS Module with all CSS Custom Properties Global Styling Hooks coming soon!
  • 26. SLDS Validator VSCode plugin Part of Salesforce Extension pack Smart Suggestions Recommended tokens and utility classes, in CSS and HTML Save Time Syntax highlighting and code completion
  • 27. Summary ● Understand Shadow DOM and the different implementations in LWC ● Master CSS: cascading, inherited and custom properties ● Styling hooks, Aura design tokens and SLDS design token ● Know and choose the best ways to import and share your CSS ● SLDS Validator is your friend!