Lightning Web Components – Hide Specific Attributes from Lightning Web Components

lightning-web-components

Lightning web components come with attributes. For my use case, I do not need all these attributes and I would like to hide them.

For example, the Lightning combobox has some of the following attributes:

<template>
    <lightning-combobox
            name="progress"
            label="Status"
            value={value}
            placeholder="Select Progress"
            options={options}
            onchange={handleChange} ></lightning-combobox>

    <p>Selected value is: {value}</p>
</template>

When the HTML Generates on the page it always adds an HTML element for the label. This takes up space on the page that I do not want. For my use case, I do not need this element and would like to hide it from the layout.

Within the attributes, is it possible to tell the component to specifically not generate? For example, I would like to set the label attribute to "Hide"

The full SFDC component documentation can be found here

Best Answer

You can set the variant attribute as label-hidden. As per the documentation, use label-hidden to hide the label but make it available to assistive technology.

Related Topic