2

This question already has an answer here:

I am using lightning:input for autocomplete (ui:inputText doesn't really work here correctly as it doesn't update value until you remove focus from field):

                <lightning:input
                      label=" "
                      placeholder="Opportunity or Project"
                      name="myname"
                      onchange="{!c.searchOpportunities}"
                      value="{!v.newRecord.opportunity}"/>

However, I do not like the whitespace left above the field. What is the right way to remove it? It's kind of annoying that its required in first place, esp. when we have alternatives like placeholder (I know I know, semantically it's not the same, but in some cases it makes sense to use placeholder).

marked as duplicate by Praveen, Martin Lezer, Raul, Ratan Paul, Santanu Boral May 18 '17 at 14:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

unfortunately you cannot remove label from lightning:input. Its a required property.You can get around it by giving a space like you did.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_input.htm

Btw, if you remove label the component will go blank.

We had a similar issue(when we set label = " "),what we did was through CSS removed extra margin/padding to ensure blank space doesn't get added for input box.

  • Actually found my answer here: salesforce.stackexchange.com/questions/160897/… Not sure why I wasn't able to Google it out in first place. – dzh May 18 '17 at 2:31
  • No worries. At least from your comments future readers can take a look at that and help themselves. – RedDevil May 18 '17 at 3:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.