Shadow Dom Style in Vaadin Flow

Viewed 768

I've written a vaadin flow wrapper for this polymer element:

@Tag("simple-dropdown")
@HtmlImport("bower_components/simple-dropdown/simple-dropdown.html")
public class DropdownMenu extends Component implements HasComponents, HasSize, HasStyle {
    ...
}

This works. The documentation of simple-dropdown tells me I can style the shadow dom with this css:

simple-dropdown {
    --simple-dropdown-toggle: {
        justify-content: right;
    }
}

However, I'm unable to find the right place for this css in Vaadin flow. Where do I have to put it?

2 Answers

You may use it where the parent's style, something like:

my-element.html

 <link rel="import" href="polymer/polymer.html"> 
 <dom-module id='my-element'>
 <template>
    <style>
        :host {
          display:block;
        }
        simple-dropdown {
           --simple-dropdown-toggle: {
                  justify-content: right;
            }
        }

    </style>

    <simple-dropdown origin="top right" label="menu" arrow>
          <a href="#">item</a>
    </simple-dropdown>
 </template>

webapp/frontend/styles/shared-styles.html

<custom-style>
    <style>
        simple-dropdown {
            --simple-dropdown-toggle: {
                justify-content: right;
            };
        }
    </style>
</custom-style>

Then, on the toplevel layout (not the flow wrapper!)

@HtmlImport("frontend://styles/shared-styles.html")
public class MainView extends Div {
...
}
Related