Skip to content

[lion-button] How to apply class names when extending #1158

Answered by jorenbroekema
jdelight asked this question in Q&A
Discussion options

You must be logged in to vote

With LionButton and also other Lion fields that wrap native fields, it is a little bit special indeed. This is because we spawn the native <button> or native <input> in case of LionInput for example, inside the LightDOM. This is for accessibility reasons, because the field has to be in the same DOM as the label. For button, it's mostly for supporting (native) form submission.

The usual way would be to just override the styles:

static get styles() {
  return [
    super.styles,
    css`
      :host {
        background-color: blue;
      }
    `,
  ];
}

But as you mentioned, it requires you to pull the CSS rules out of your CSS blocks and paste them into :host selector in your extension.


T…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jdelight
Comment options

Answer selected by jorenbroekema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants