Can you add custom styling to HTML within a Polymer paper-item component?

I am attempting to include rich content inside the elements of a paper-menu. However, it seems that this is not working as intended (refer to the screenshot below).

What steps should be taken to incorporate styled HTML into the paper-item?

Below is the provided code:

<style is="custom-style">
    .personItem {
        @apply(--layout-horizontal);
        margin: 16px 16px 0 16px;
        padding: 20px;
        border-radius: 8px;
        background-color: white;
        border: 1px solid #ddd;
    }
    .avatar {
        height: 50px;
        width: 50px;
        border-radius: 25px;
        box-sizing: border-box;
        background-color: #DDD;
    }
    .pad {
        padding: 0 16px;
        @apply(--layout-flex);
        @apply(--layout-vertical);
    }
    .primary {
        font-size: 16px;
        font-weight: bold;
    }
        .dim {
        color: gray;
    }
</style>

<paper-menu-button vertical-align="top" horizontal-align="right" vertical-offset="64">
    <paper-icon-button id="notif" icon="social:notifications" class="dropdown-trigger" alt="menu"></paper-icon-button>
    <paper-menu class="dropdown-content">
        <template is="dom-repeat" items="[[notifications]]" as="item">
            <paper-item>
                <paper-item-body two-line>
                    <!--<div th:inline="none"><iron-icon icon='communication:message'></iron-icon></div>-->
                    <div secondary th:inline="none">
                        <div class="personItem">
                            <iron-image class="avatar" sizing="contain" src="[[item.pic]]"></iron-image>
                            <div class="pad">
                                <div class="primary" th:inline="none">
                                    <span style="float:right;">[[m.date]]</span>
                                    <span>[[m.user]]</span>
                                </div>
                                <div class="dim" th:inline="none">[[m.content]]</div>
                            </div>
                        </div>
                    </div>
                </paper-item-body>
            </paper-item>
        </template>
    </paper-menu>
</paper-menu-button>
<paper-badge id="badge" for="notif" label="[[number]]"></paper-badge>

https://i.sstatic.net/XQz3a.png

Answer №1

I was able to achieve my desired outcome with the following code snippet:

<paper-menu-button>
    <paper-icon-button id="n" icon="social:notifications" class="dropdown-trigger" alt="menu"></paper-icon-button>
    <paper-menu class="dropdown-content">
        <template is="dom-repeat" items="[[notifications]]" as="item">
            <paper-icon-item>
                <iron-icon item-icon class="avatar" sizing="contain" src="/path/to/pic"></iron-icon>
                <paper-item-body two-line>
                    <div>John Doe</div>
                    <div secondary>Hello World</div>
                </paper-item-body>
                <paper-icon-button icon="communication:message"></paper-icon-button>
            </paper-icon-item>
        </template>
    </paper-menu>
</paper-menu-button>
<paper-badge id="badge" for="n" label="[[number]]"></paper-badge>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The v-checkbox appears much larger in size and has a different row size when compared to the v-radio

Currently, I am working on an application using Vuejs 3 with Vuetifyjs 3, and I have encountered an issue regarding the row size difference between a v-checkbox and v-radio when set to density="compact". The discrepancy in line height can be seen in the im ...

Require the implementation of seamless scrolling when clicking on an anchor tag with a specific ID, as opposed to the abrupt jumping to the corresponding

<div id="slider"> <div id="pro1"></div> <div id="pro2"></div> <div id="pro3"></div> </div> <div id="thumb"> <a href="#pro1"> <img id="tpro1" src="projects/tpro5.jpg" style="hei ...

Two tables are positioned using distinct alignments but share a common stylesheet

I have created two tables, one using HTML (with a touch of PHP) and the other with two PHP loops. Starting with the stylesheet: .statistics { font-family: Arial, monospace; font-size: 36px; margin-left: 5%; width: 90%; } .statistics tr { ...

issues with the styling and scripts within the jsp document

During my project work, I encountered an issue with the front end as shown in the image below. https://i.sstatic.net/gLIUr.png Upon loading the project, all styles and scripts disappear completely. How can I resolve this issue promptly? I attempted to up ...

Toggling javascript functionality based on media queries

On one of my slides, I want to display images that are specific to different devices like iPhone, iPad, and desktop. I am looking for a way to filter these images based on the device. Using display:none won't work as it's JavaScript, but here is ...

Positioning a fixed div within a responsive div using AngularJS and Bootstrap

I'm currently working on a page layout that consists of a fixed sidebar on the left side and a main container taking up the rest of the page on the right. Inside this right-side container, which is a div, there are 2 elements. <div class="col-sm-1 ...

How to align scrolling images with their scroll origin - a step by step guide

Curious to know the name of the effect where images scroll in a different orientation than the page, creating a 2D appearance. Take a look at the Google Nexus website and scroll down - do you see the effect? What is this effect called? Is it created usin ...

The slideshow feature in Bootstrap carousel seems to be malfunctioning

I can't seem to get my Bootstrap carousel slideshow to work properly. When I run the code in my Angular app.component.html, only the first image loads with no animations or response to control buttons. I've checked all the CDNs and they are worki ...

Adjust the text color to complement the shifting background shade

I'm looking to customize the hover color of my links to match the constantly changing background. You can view my progress on this in the JSFiddle linked below: https://jsfiddle.net/Lcz7gk72/ Essentially, I want the "[email protected]" text to b ...

Is it possible to remove certain 'css-' class names that MUI automatically applies to its components? (Using Next JS and MUI)

After successfully migrating my create-react-app project to Next JS using the latest version (12.1.0) and following the migration guide at https://nextjs.org/docs/migrating/from-create-react-app, I encountered an unexpected issue. Despite still using MUI a ...

Seamless scrolling experience achieved after implementing a header that appears when scrolling up

My goal is to create a header with the following functionalities: Initially displays with a transparent background Upon scrolling down the page by 25px, it will dynamically add the header--maroon class to the header, which alters the background color and ...

The ultimate guide to personalizing group titles in Angular UI-Select

Is there a way in Angular ui-select to customize the group label? I want to make it larger than the selection items as shown in the image below. https://i.stack.imgur.com/ofcak.png The list is currently grouped by country, but how can I adjust the size o ...

Ensure that all lists are aligned on the left side, from the numbers to

Trying to implement a solution for aligning numbers and text in an ordered list within a border. Found a helpful answer on Stack Overflow: Left align both list numbers and text Encountering an issue where long content in one list item overlaps into the n ...

Top method for utilizing jQuery to locate, sift through, and implement CSS classes

Let's consider the following scenario: <span class="foo">7</span> <span class="foo">2</span> <span class="foo">9</span> We want to assign a CSS class of 'highest' to 'span.foo' with value great ...

Discover the magic of Bootstrap 3.0 Popovers and Tooltips

I'm struggling with implementing the popover and tooltip features in Bootstrap. While I have successfully implemented drop downs and modals, the tooltips are not styled or positioned correctly as shown in the Bootstrap examples, and the popover featur ...

Set the modal-dialog to have a fixed width, but ensure that it becomes responsive and adjusts size appropriately when the screen size becomes smaller

Utilizing the default Bootstrap3 CSS files for my project. I've come across an issue where the modal-dialog width is set to 600px by default, while I require it to be 1000px for my screen size. Regardless of the screen size exceeding 1000px, I need t ...

The choices in the cell table selection are obscured due to the select table's height when opened

I am experiencing an issue with a table where each row contains two cells with "select" options. The problem arises when I open them, as they load within the table and the available options are not clearly visible. I can only view all the options by scroll ...

The styling of divIcons in React Leaflet Material UI is not applied as expected

When using divIcon in React Leaflet to render a custom Material UI marker with a background color prop, I noticed that the background style is not being applied correctly when the marker is displayed in Leaflet. Below you can find the code for the project ...

JavaScript and jQuery code: Trigger the vjs-fade-out class to toggle when the userActive value in video.js changes

I am currently utilizing video.js to develop a player that is compatible with various devices. One crucial feature I have included is a custom "return to menu" button located in the top right corner of the video player. The challenge I am facing is dynamic ...

What could be causing the inability of select:-moz-focusring to eliminate the dotted lines in the Firefox browser on this bootstrap navigation

Is there a way to remove the Firefox dotted lines from my bootstrap navigation bar? I've come across suggestions to add the following code snippet to the CSS file: a:-moz-focusring { color: transparent; text-shadow: 0 0 0 #000; ...