8000 Support styling components from outside with style hooks · Issue #10663 · angular/angular · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Support styling components from outside with style hooks #10663
Closed
@aegyed91

Description

@aegyed91

I'm submitting a feature request:

In Shadow DOM you can create style hooks using CSS custom properties. It is possible in polymer too with custom-css-mixins.

Angular should support style hooks / or style projections.

Here is the syntax:

@Component({
  selector: 'ns-button',
  template: `
    <button>
      <i class="icon fa fa-fw fa-star"></i>
      <ng-content></ng-content>
    </button>
  `,
  styles: [`
    :host { 
      display: inline-block;

      /* projects --ns-button styles, this is like <ng-content></ng-content> 
        on the template level */
      @apply(--ns-button);
    }
    .icon {
      height: auto;
      max-width: 35px;
      @apply(--ns-button-icon)
    }
  `]
})
class NsButton {
}

@Component({
  selector: 'ns-app',
  template: `<ns-button>Click me!</ns-button>`,
  styles: [`
    ns-button {
      /* this is how you feed it with input, this is like ContentChild
       on the template level */
      --ns-button: {
        background-color: green;
        border-radius: 4px;
        border: 1px solid gray;
      };
      --ns-button-icon: {
        color: green;
      };
    }
  `]
})
class NsApp {
}

@pkozlowski-opensource @Foxandxss

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: stylesheetsfeatureIssue that requests a new featurefeature: insufficient votesLabel to add when the not a sufficient number of votes or comments from unique authorsfeature: votes requiredFeature request which is currently still in the voting phasefreq2: medium

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0