CSS file won't apply to Lightning Web ComponentSet CSS class dynamically in Lightning web componentlwc: sfdx...

Fermat's polygonal number theorem

A man condemned to serve his sentence in other times

Is the tap water in France safe to drink?

Remove last letter 4 times, get a real word each time, starting word is a car model

Could an American state survive nuclear war?

What power does the UK parliament hold over a Prime Minister whom they refuse to remove from power?

Unexpected exec permission from mmap when assembly files included in the project

Accidental duration in measureless music

What could possibly power an Alcubierre drive?

My Guitar came with both metal and nylon strings, what replacement strings should I buy?

Are there any spells that enhance ranged attacks like some melee attack spells do for melee attacks

If I did not sign promotion bonus document, my career would be over. Is this duress?

Can we not simply connect a battery to a RAM to prevent data loss during power cuts?

I need an automatic way of making a lot of folders

How to respond to "Why didn't you do a postdoc after your PhD?"

How could a steampunk zeppelin navigate space?

Why do Computer Science degrees contain a high proportion of mathematics?

What does this text mean with capitalized letters?

Does my protagonist need to be the most important character?

Is it safe to pay bills over satellite internet?

How do you handle simultaneous damage when one type is absorbed and not the other?

Could a solar system exist inside of a nebula which is made of breathable gases?

Usefulness of Nash embedding theorem

In the twin paradox does the returning twin also come back permanently length contracted flatter than the twin on earth?



CSS file won't apply to Lightning Web Component


Set CSS class dynamically in Lightning web componentlwc: sfdx unable to retrieve lwc filesLightningComponentBundle “Not available for deploy for this API version” errorSLDS Button refreshing entire page on click in LWCCss not working in Lightning Web ComponentHow to adjust min-height of Salesforce Lightning input rich text component on loadHandsontable 3rd party library not working in LWCapplying styles to several html templates with single css fileLWC lightning-input-field for a checkbox field in lightning-record-edit-form, the field can only be saved once?Overwrite standard lightning web component css by class name






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{
margin-bottom:0;
}








1

















Trying to apply some basic CSS to a button on my LWC and can't seem to get it to apply. I followed all the basic guidelines in terms of containing the CSS file within the same folder as my LWC. It deploys without issue



=== Deployed Source
STATE FULL NAME TYPE PROJECT PATH
───── ──────────────────────────── ────────────────────────
──────────────────────────────────────────────────────────────
Add pcMaterialspcMaterials.css LightningComponentBundle force-
appmaindefaultlwcpcMaterialspcMaterials.css

Add pcMaterialspcMaterials.html LightningComponentBundle force-
appmaindefaultlwcpcMaterialspcMaterials.html

Add pcMaterialspcMaterials.js LightningComponentBundle force-
appmaindefaultlwcpcMaterialspcMaterials.js

Add pcMaterialspcMaterials.js LightningComponentBundle force-
appmaindefaultlwcpcMaterialspcMaterials.js-meta.xml


It has the same name as the LWC so it should be applied automatically (at least according to the documentation



HTML File



<template>
<lightning-card variant="narrow"
icon-name="standard:opportunity"
title="PC Materials">
<lightning-button label="New" slot="actions" class="normalField">
</lightning-button>
<lightning-button label="All"></lightning-button>
<lightning-button label="My Materials" onclick={handleClick}></lightning-
button>
<!--<lightning-input type="search"
onchange={handleSearchTermChange}
variant="label-hidden"
class="slds-m-bottom_small"
label="Search"
placeholder="Search"
value={searchTerm}>
</lightning-input>-->
<lightning-datatable
key-field="id"
data={aidata}
hide-checkbox-column = true
columns={columns}
onsave={handleSave}>
</lightning-datatable>
</lightning-card>
</template>


CSS File



.normalField {
color: red;
background: red;
}









share|improve this question

































    1

















    Trying to apply some basic CSS to a button on my LWC and can't seem to get it to apply. I followed all the basic guidelines in terms of containing the CSS file within the same folder as my LWC. It deploys without issue



    === Deployed Source
    STATE FULL NAME TYPE PROJECT PATH
    ───── ──────────────────────────── ────────────────────────
    ──────────────────────────────────────────────────────────────
    Add pcMaterialspcMaterials.css LightningComponentBundle force-
    appmaindefaultlwcpcMaterialspcMaterials.css

    Add pcMaterialspcMaterials.html LightningComponentBundle force-
    appmaindefaultlwcpcMaterialspcMaterials.html

    Add pcMaterialspcMaterials.js LightningComponentBundle force-
    appmaindefaultlwcpcMaterialspcMaterials.js

    Add pcMaterialspcMaterials.js LightningComponentBundle force-
    appmaindefaultlwcpcMaterialspcMaterials.js-meta.xml


    It has the same name as the LWC so it should be applied automatically (at least according to the documentation



    HTML File



    <template>
    <lightning-card variant="narrow"
    icon-name="standard:opportunity"
    title="PC Materials">
    <lightning-button label="New" slot="actions" class="normalField">
    </lightning-button>
    <lightning-button label="All"></lightning-button>
    <lightning-button label="My Materials" onclick={handleClick}></lightning-
    button>
    <!--<lightning-input type="search"
    onchange={handleSearchTermChange}
    variant="label-hidden"
    class="slds-m-bottom_small"
    label="Search"
    placeholder="Search"
    value={searchTerm}>
    </lightning-input>-->
    <lightning-datatable
    key-field="id"
    data={aidata}
    hide-checkbox-column = true
    columns={columns}
    onsave={handleSave}>
    </lightning-datatable>
    </lightning-card>
    </template>


    CSS File



    .normalField {
    color: red;
    background: red;
    }









    share|improve this question





























      1












      1








      1








      Trying to apply some basic CSS to a button on my LWC and can't seem to get it to apply. I followed all the basic guidelines in terms of containing the CSS file within the same folder as my LWC. It deploys without issue



      === Deployed Source
      STATE FULL NAME TYPE PROJECT PATH
      ───── ──────────────────────────── ────────────────────────
      ──────────────────────────────────────────────────────────────
      Add pcMaterialspcMaterials.css LightningComponentBundle force-
      appmaindefaultlwcpcMaterialspcMaterials.css

      Add pcMaterialspcMaterials.html LightningComponentBundle force-
      appmaindefaultlwcpcMaterialspcMaterials.html

      Add pcMaterialspcMaterials.js LightningComponentBundle force-
      appmaindefaultlwcpcMaterialspcMaterials.js

      Add pcMaterialspcMaterials.js LightningComponentBundle force-
      appmaindefaultlwcpcMaterialspcMaterials.js-meta.xml


      It has the same name as the LWC so it should be applied automatically (at least according to the documentation



      HTML File



      <template>
      <lightning-card variant="narrow"
      icon-name="standard:opportunity"
      title="PC Materials">
      <lightning-button label="New" slot="actions" class="normalField">
      </lightning-button>
      <lightning-button label="All"></lightning-button>
      <lightning-button label="My Materials" onclick={handleClick}></lightning-
      button>
      <!--<lightning-input type="search"
      onchange={handleSearchTermChange}
      variant="label-hidden"
      class="slds-m-bottom_small"
      label="Search"
      placeholder="Search"
      value={searchTerm}>
      </lightning-input>-->
      <lightning-datatable
      key-field="id"
      data={aidata}
      hide-checkbox-column = true
      columns={columns}
      onsave={handleSave}>
      </lightning-datatable>
      </lightning-card>
      </template>


      CSS File



      .normalField {
      color: red;
      background: red;
      }









      share|improve this question














      Trying to apply some basic CSS to a button on my LWC and can't seem to get it to apply. I followed all the basic guidelines in terms of containing the CSS file within the same folder as my LWC. It deploys without issue



      === Deployed Source
      STATE FULL NAME TYPE PROJECT PATH
      ───── ──────────────────────────── ────────────────────────
      ──────────────────────────────────────────────────────────────
      Add pcMaterialspcMaterials.css LightningComponentBundle force-
      appmaindefaultlwcpcMaterialspcMaterials.css

      Add pcMaterialspcMaterials.html LightningComponentBundle force-
      appmaindefaultlwcpcMaterialspcMaterials.html

      Add pcMaterialspcMaterials.js LightningComponentBundle force-
      appmaindefaultlwcpcMaterialspcMaterials.js

      Add pcMaterialspcMaterials.js LightningComponentBundle force-
      appmaindefaultlwcpcMaterialspcMaterials.js-meta.xml


      It has the same name as the LWC so it should be applied automatically (at least according to the documentation



      HTML File



      <template>
      <lightning-card variant="narrow"
      icon-name="standard:opportunity"
      title="PC Materials">
      <lightning-button label="New" slot="actions" class="normalField">
      </lightning-button>
      <lightning-button label="All"></lightning-button>
      <lightning-button label="My Materials" onclick={handleClick}></lightning-
      button>
      <!--<lightning-input type="search"
      onchange={handleSearchTermChange}
      variant="label-hidden"
      class="slds-m-bottom_small"
      label="Search"
      placeholder="Search"
      value={searchTerm}>
      </lightning-input>-->
      <lightning-datatable
      key-field="id"
      data={aidata}
      hide-checkbox-column = true
      columns={columns}
      onsave={handleSave}>
      </lightning-datatable>
      </lightning-card>
      </template>


      CSS File



      .normalField {
      color: red;
      background: red;
      }






      lightning-web-components css






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question



      share|improve this question










      asked 8 hours ago









      BobbygllhBobbygllh

      688 bronze badges




      688 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          3


















          The CSS is being "applied", but the problem is that you can't modify most attributes of a component because of the Shadow DOM. This means that you can, for example, set the border of a component, or its width and height, but you can't change its font color or other attributes. You'll want to read more about the current limitations for CSS styles in components. The only allowed color changes are to use the variant attribute to change the color. For example, you could say:



          <lightning-button label="New" slot="actions" variant="destructive"></lightning-button>


          Check the documentation for other possible variants.



          If you need greater control than what's allowed by the component, you'll need to write your own instead. You can use lightning buttons from SLDS to get started.






          share|improve this answer



























          • bit frustrating but makes sense in the longrun. Thought the switch to component specific CSS would allow more functionality in that regard, not less

            – Bobbygllh
            6 hours ago



















          0


















          Set your lightning-button variant to base. By default, a button's variant is neutral and that sets the background to be white which is overriding the CSS applied in some way.



          See an example in the playground here:
          https://developer.salesforce.com/docs/component-library/tools/playground/AX7c7dCxd/1/edit



          This all being said, if you need to totally customize your button, don't use the lightning-button component and instead use an HTML button or create your own button component.






          share|improve this answer






























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "459"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });















            draft saved

            draft discarded
















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f280643%2fcss-file-wont-apply-to-lightning-web-component%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown


























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3


















            The CSS is being "applied", but the problem is that you can't modify most attributes of a component because of the Shadow DOM. This means that you can, for example, set the border of a component, or its width and height, but you can't change its font color or other attributes. You'll want to read more about the current limitations for CSS styles in components. The only allowed color changes are to use the variant attribute to change the color. For example, you could say:



            <lightning-button label="New" slot="actions" variant="destructive"></lightning-button>


            Check the documentation for other possible variants.



            If you need greater control than what's allowed by the component, you'll need to write your own instead. You can use lightning buttons from SLDS to get started.






            share|improve this answer



























            • bit frustrating but makes sense in the longrun. Thought the switch to component specific CSS would allow more functionality in that regard, not less

              – Bobbygllh
              6 hours ago
















            3


















            The CSS is being "applied", but the problem is that you can't modify most attributes of a component because of the Shadow DOM. This means that you can, for example, set the border of a component, or its width and height, but you can't change its font color or other attributes. You'll want to read more about the current limitations for CSS styles in components. The only allowed color changes are to use the variant attribute to change the color. For example, you could say:



            <lightning-button label="New" slot="actions" variant="destructive"></lightning-button>


            Check the documentation for other possible variants.



            If you need greater control than what's allowed by the component, you'll need to write your own instead. You can use lightning buttons from SLDS to get started.






            share|improve this answer



























            • bit frustrating but makes sense in the longrun. Thought the switch to component specific CSS would allow more functionality in that regard, not less

              – Bobbygllh
              6 hours ago














            3














            3










            3









            The CSS is being "applied", but the problem is that you can't modify most attributes of a component because of the Shadow DOM. This means that you can, for example, set the border of a component, or its width and height, but you can't change its font color or other attributes. You'll want to read more about the current limitations for CSS styles in components. The only allowed color changes are to use the variant attribute to change the color. For example, you could say:



            <lightning-button label="New" slot="actions" variant="destructive"></lightning-button>


            Check the documentation for other possible variants.



            If you need greater control than what's allowed by the component, you'll need to write your own instead. You can use lightning buttons from SLDS to get started.






            share|improve this answer














            The CSS is being "applied", but the problem is that you can't modify most attributes of a component because of the Shadow DOM. This means that you can, for example, set the border of a component, or its width and height, but you can't change its font color or other attributes. You'll want to read more about the current limitations for CSS styles in components. The only allowed color changes are to use the variant attribute to change the color. For example, you could say:



            <lightning-button label="New" slot="actions" variant="destructive"></lightning-button>


            Check the documentation for other possible variants.



            If you need greater control than what's allowed by the component, you'll need to write your own instead. You can use lightning buttons from SLDS to get started.







            share|improve this answer













            share|improve this answer




            share|improve this answer



            share|improve this answer










            answered 8 hours ago









            sfdcfoxsfdcfox

            288k14 gold badges237 silver badges498 bronze badges




            288k14 gold badges237 silver badges498 bronze badges
















            • bit frustrating but makes sense in the longrun. Thought the switch to component specific CSS would allow more functionality in that regard, not less

              – Bobbygllh
              6 hours ago



















            • bit frustrating but makes sense in the longrun. Thought the switch to component specific CSS would allow more functionality in that regard, not less

              – Bobbygllh
              6 hours ago

















            bit frustrating but makes sense in the longrun. Thought the switch to component specific CSS would allow more functionality in that regard, not less

            – Bobbygllh
            6 hours ago





            bit frustrating but makes sense in the longrun. Thought the switch to component specific CSS would allow more functionality in that regard, not less

            – Bobbygllh
            6 hours ago













            0


















            Set your lightning-button variant to base. By default, a button's variant is neutral and that sets the background to be white which is overriding the CSS applied in some way.



            See an example in the playground here:
            https://developer.salesforce.com/docs/component-library/tools/playground/AX7c7dCxd/1/edit



            This all being said, if you need to totally customize your button, don't use the lightning-button component and instead use an HTML button or create your own button component.






            share|improve this answer

































              0


















              Set your lightning-button variant to base. By default, a button's variant is neutral and that sets the background to be white which is overriding the CSS applied in some way.



              See an example in the playground here:
              https://developer.salesforce.com/docs/component-library/tools/playground/AX7c7dCxd/1/edit



              This all being said, if you need to totally customize your button, don't use the lightning-button component and instead use an HTML button or create your own button component.






              share|improve this answer































                0














                0










                0









                Set your lightning-button variant to base. By default, a button's variant is neutral and that sets the background to be white which is overriding the CSS applied in some way.



                See an example in the playground here:
                https://developer.salesforce.com/docs/component-library/tools/playground/AX7c7dCxd/1/edit



                This all being said, if you need to totally customize your button, don't use the lightning-button component and instead use an HTML button or create your own button component.






                share|improve this answer
















                Set your lightning-button variant to base. By default, a button's variant is neutral and that sets the background to be white which is overriding the CSS applied in some way.



                See an example in the playground here:
                https://developer.salesforce.com/docs/component-library/tools/playground/AX7c7dCxd/1/edit



                This all being said, if you need to totally customize your button, don't use the lightning-button component and instead use an HTML button or create your own button component.







                share|improve this answer















                share|improve this answer




                share|improve this answer



                share|improve this answer








                edited 8 hours ago

























                answered 8 hours ago









                nbrownnbrown

                5342 silver badges12 bronze badges




                5342 silver badges12 bronze badges


































                    draft saved

                    draft discarded



















































                    Thanks for contributing an answer to Salesforce Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f280643%2fcss-file-wont-apply-to-lightning-web-component%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown









                    Popular posts from this blog

                    Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

                    The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

                    Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...