I have a simple component being called from another component that I was to add a margin value to.
Example:
Child component:
import { Component } from '@stencil/core';
@Component({
tag: 'app-header',
styleUrl: 'app-header.css',
shadow: false
})
export class AppHeader {
render() {
return (
<div class='app-header-component'>
Hey I'm a header
</div>
);
}
}
The parent component
import { Component } from '@stencil/core';
@Component({
tag: 'app-home',
styleUrl: 'app-home.css'
})
export class AppHome {
render() {
return (
<div class='app-home'>
<app-header></app-header>
</div>
);
}
}
Parent component styles
// app-home.css
app-header {
margin-top: 1rem;
}
How could I apply styles to a child component?
EDIT
I realized I can target the components child and then apply the styles.
// app-home.css
app-header {
.app-header-component {
margin-top: 1rem;
}
}