Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
Style :host in Lit component overrides style :host in mixin

When a lit component extends a mixin, style in component overrides style in mixin.

Example:

my-component.js

export class HomePage extends ViewMixin(LitElement) {
  static styles = css`
    :host {
      color: blue;
    }
  `;

view-mixin.js

export const ViewMixin = superClass => {
  class ViewMixinElement extends superClass {
    static styles = css`
      :host {
         background-color: red;
      }
    `;

The component will render with color=blue but background will not be red. How can I add background-color=red to all views while adding specific :host styling per view ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I got your question correctly, you need to extend styles in you child component. There is a way to do it like this:

import { css } from 'lit';

import { BaseButton } from './BaseButton.js';
import { buttonStyles } from './buttonStyles.js';


export class EnhancedButton extends BaseButton {
  static styles = [
    BaseButton.styles,
    buttonStyles,
    css`div {
      background-color: red;
    }`
  ];
}

I also added buttonStyles to make it clear how you could pass several styles in an array. Or have you styles in a separate file while extending the BaseButton.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!