# \[ionic-v4\] shadow-dom

**URL:** <https://forum.ionicframework.com/t/ionic-v4-shadow-dom/137350>\
**Category:** Ionic Framework\
**Created:** [August 4, 2018, 6:41am UTC](https://forum.ionicframework.com/t/ionic-v4-shadow-dom/137350 "2018-08-04T06:41:55Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![MrTrieu](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@MrTrieu](https://forum.ionicframework.com/u/MrTrieu)\
**Post date:** [August 5, 2018, 9:22am UTC](https://forum.ionicframework.com/t/ionic-v4-shadow-dom/137350/3 "2018-08-05T09:22:51Z")

</div>

Thank for your reply and your blog is very helpful.  
I found my solution to this problem

I create a directive and write my custom CSS to shadowRoot.

```auto
import { Directive, ElementRef, Input, OnChanges } from '@angular/core';
@Directive({
  selector: '[appShadowCss]'
})
export class ShadowCssDirective implements OnChanges {
  @Input() shadowCustomCss: string;

  ngOnChanges(): void {
    const shadow = this.el.nativeElement.shadowRoot || this.el.nativeElement.attachShadow({ mode: 'open' });
    if (shadow) {
      let innerHTML = '';
      innerHTML += '<style>';
      innerHTML += this.shadowCustomCss;
      innerHTML += '</style>';
      shadow.innerHTML += innerHTML;
    }
  }
  constructor(private el: ElementRef) {

  }

}

<ion-button expand="block" fill="outline" appShadowCss shadowCustomCss='.button-inner{white-space:normal;}'>
             Edit your phone number.
</ion-button>

```

I know It is a very bad idea to do this in every button.  
Do you know how to disable shadow root in ionic?

---

_[View the full topic](https://forum.ionicframework.com/t/ionic-v4-shadow-dom/137350)._
