remove Space between labels and input in lwc -- w3web.net

How to remove/put the extra space between label and lightning-input field Uses of Style CSS property in LWC – Lightning Web Component | How to reduce space horizontally between label and input using Style CSS property in Lightning Web Component – LWC

2,325 views

Hey guys, today in this post we are going to learn about How to reduce space horizontally between label and lightning-input using Style CSS property in Lightning Web Component – LWC.

The Form Element is initialized with slds-form-element and is made up of three primary pieces; a label (slds-form-element__label), a form control container (slds-form-element__control), and a form input element.

A form label should use either the label or legend elements with the class slds-form-element__label.

A form control is a div with the class slds-form-element__control. The control is required to maintain the structure of the Form Element.

There are many types of input elements that can be used in the Form Element, including inputs, text areas, checkboxes, and radio buttons. To know more details, Click Here →

Files we used to remove Space between labels and input in LWC →

lwcLabelAndInputSpace.html LWC HTML File Template HTML file to remove the Space between labels and input in LWC
lwcLabelAndInputSpace.js LWC JavaScript File In the javascript file create import/export function in LWC
lwcLabelAndInputSpace.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.
lwcLabelAndInputSpace.css Style CSS It is used to remove the space between labels and lightning-input using style CSS property.
lwcLabelAndInputSpaceApp.app Lightning Application It is used to call the component to preview on browser.

 

 

Final Output →

remove Space between labels and input in lwc -- w3web.net

 

Other related post that would you like to learn in Salesforce

 

  • Find the below steps ▾

 

Create Lightning Web Component HTML →

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

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

lwcLabelAndInputSpace.html [Lightning Web Component HTML]

 

Create Lightning Web Component JavaScript →

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

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

lwcLabelAndInputSpace.js [LWC JavaScript File]

 

Create LWC Style CSS →

Step 3:- Create Style CSS : lwcLabelAndInputSpace.css

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

lwcLabelAndInputSpace.css [Style CSS]

Create Lightning Web Component Meta XML →

Step 4:- Create Lightning Web Component : lwcLabelAndInputSpace.js-meta.xml

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

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

 

Create Lightning Application →

Step 5:- Create Lightning Application : lwcLabelAndInputSpaceApp.app

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

lwcLabelAndInputSpaceApp.app [Component Application File]

 
remove Space between labels and input in lwc -- w3web.net
 

Further post that would you like to learn in Salesforce

 


 

FAQ (Frequently Asked Questions)

How do you reduce space between label and input?

If you have no margin or padding applied and you still have this space, you could either use display: flex on the parent or display: block/inline-block on the label to get rid of these. Both label and input are display: inline , per default, so margin and padding bottom or top should not affect them.

How do you hide input fields in lightning component?

You could use SLDS styling classes, . slds-hide or . slds-hidden , to hide your component from user and let it hold the value for later use.

How do I add a space between elements in CSS?

The CSS padding properties are used to generate space around an element's content, inside of any defined borders. With CSS, you have full control over the padding. There are properties for setting the padding for each side of an element (top, right, bottom, and left).

Related Topics | You May Also Like

  • Your reaction of the article ▾
 

Hi, This is Vijay Kumar 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

Leave a Comment