Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

249
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda