How to add dynamic css inline class add/remove, toggle and zoom-up/zoom-out style based on button click in Salesforce Lightning Web Component (LWC) | How to use inline class for the animation CSS style to show/hide and Toggle container based on button click in Salesforce LWC (Lightning Web Componenet)

Vijayk
3 min readFeb 26, 2022

Hey guys, today in this post we are going to learn about How to use inline class for the animation CSS style to show/hide and Toggle container based on button click in Salesforce LWC (Lightning Web Componenet).

Style Components with Lightning Design System

Salesforce Lightning Design System (SLDS) is a CSS framework that provides a look and feel that’s consistent with Lightning Experience. Use SLDS styles to give your custom Lightning web components a UI that is consistent with Salesforce, without having to reverse-engineer our styles. And best of all, it just works with Lightning components running in Lightning Experience and in the Salesforce mobile application. To know more details about Salesforce Lightning Design System (SLDS), Click Here..

Files we used to add inline class in Salesforce LWC →

lwcInlineStyleCss.html

LWc HTML File

Template HTML file to create dynamic css inline class add/remove based on button click in Salesforce Lightning Web Component (LWC)

lwcInlineStyleCss.js

LWC JavaScript File

It’s javascript actions functions to control the animation CSS style show/hide & Toggle container in Salesforce LWC

lwcInlineStyleCss.js-meta.xml

XML Meta File

It is used to where this lightning web component file you want to display as lightning__AppPage, lightning__RecordPage, lightning__HomePage.

lwcInlineStyleCss.css

Style CSS

It is used to creaet animation CSS style and alignment of the container.

lwcInlineStyleCssApp.app

Lightning Application

It is used for call the component and preview on browser.

Final Output → To get source code, live demo link..

Other related post that would you like to learn in LWC

Create Lightning Web Component HTML →

Step 1:- Create Lightning Web Component : lwcInlineStyleCss.html

SFDX:Lightning Web Component >> New >> lwcInlineStyleCss.html

lwcInlineStyleCss.html [Lightning Web Component HTML]

Create Lightning Web Component JavaScript →

Step 2:- Create Lightning Web Component : lwcInlineStyleCss.js

SFDX:Lightning Web Component >> New >> lwcInlineStyleCss.js

lwcInlineStyleCss.js [LWC JavaScript File]

Create Lightning Web Component Meta XML →

Step 3:- Create Lightning Web Component : lwcInlineStyleCss.js-meta.xml

SFDX:Lightning Web Component >> New >> lwcInlineStyleCss.js-meta.xml

lwcInlineStyleCss.js-meta.xml [LWC Meta Data XML]

Lightning Web Component Meta XML

Create Component Style CSS →

Step 4:- Create Lightning Web Component : lwcInlineStyleCss.css

SFDX:Lightning Web Component >> New >> lwcInlineStyleCss.css

lwcInlineStyleCss.css [Style CSS]

Create Lightning Application →

Step 5:- Create Lightning Application : lwcInlineStyleCssApp.app

From Developer Console >> File >> New >> Lightning Application

To get source code, live demo link..

Further post that would you like to learn in LWC FAQ (Frequently Asked Questions)

Hi, This is Vijay behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Originally published at https://www.w3web.net on February 26, 2022.

--

--