I am looking to customize the CSS properties of vaadin-dialog-overlay in a unique way for each view

I am working with a vaadin-dialog element that has been declared in the following way:

  render() {
    return html`
<vaadin-vertical-layout class="contents-list">
    <h2 class="osiris-block-title">Feeds Overview</h2>
    <vaadin-horizontal-layout class="osiris-block">
            <vaadin-vertical-layout class="osiris-card">
                <vaadin-horizontal-layout class="osiris-card-grid-filter" theme="spacing padding">
                    <vaadin-text-field id="search-field">
                        <vaadin-icon slot="prefix" icon="vaadin:search"></vaadin-icon>
                    </vaadin-text-field>
                    <vaadin-checkbox id="my-feeds-checkbox" label="Only my feeds"></vaadin-checkbox>
                    <vaadin-button id="filter-button">
                      Filter
                    </vaadin-button>
                    <vaadin-dialog id="filter-dialog" class="orisis-grid-filter" opened=false>
                    </vaadin-dialog>
                </vaadin-horizontal-layout>
                <vaadin-grid id="feed-grid" class="orisis-card-grid" theme="no-border row-stripes"></vaadin-grid>
            </vaadin-vertical-layout>
    </vaadin-horizontal-layout>
</vaadin-vertical-layout>`;

My aim is to customize the position of the Dialog object on the screen.

The issue here is that the vaadin-dialog tag is not actually the dialog itself. The actual dialog is a separate tag called vaadin-dialog-overlay. While I can adjust its CSS, the problem lies in the fact that this tag does not belong to the view and gets added under the body in the DOM. It does not adhere to the class of the view or the class of vaadin-dialog set within vaadin-dialog.

So, how can I reposition the dialog differently for different views?

Until now, I have only managed to reposition the dialog using something like this:

vaadin-dialog-overlay {
    align-items: end;
    justify-content: end;
    margin: var(--lumo-space-xl);
}

However, this applies to all views in the Vaadin project. I came across this answer, but I am struggling to understand how the solution "if you want to target those only, you'd write that selector as vaadin-dialog-overlay[theme="left"]::part(overlay)" can help in targeting specific overlays if I cannot manage overlay class and theme from a view?

Answer №1

It is important to note that the theme attribute should be seamlessly transferred from the dialog element to the overlay element.

Starting from version 24.0, you have the option to utilize the overlay-class attribute within the dialog, which will then be relayed as the class on the overlay:

<vaadin-dialog overlay-class="custom-dialog">

To enhance the customization, in your overarching CSS file, you can include the following snippet:

vaadin-dialog-overlay.custom-dialog::part(overlay) {
  ...
}

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 navbar in mobile view is not affected by the z-index property

Having created a navbar with scroll effect, I am encountering an issue with the mobile responsive view. Can someone please assist me in solving this problem? I would like to position the bottom nav-list below the navbar in the mobile view when clicking on ...

Switching the color of the placeholder text on a credit card

Recently, I have integrated credit card payment options into this website. To access the checkout page, you may need to add an item to your shopping cart first. Below, you will find the section where users can enter their credit card details. As part of ...

Using Inline Styling to Showcase a Background Image in a REACTJS Component

import React from 'react'; import Slick from 'react-slick'; import style from './Slider.module.css'; import {Link} from 'react-router-dom'; const SliderTemplates = (props) => { let template = null; const ...

Steps for displaying detailed information about a single product on an Ecommerce page

Currently in the process of developing my Ecommerce project, I have successfully created a product grid with links to each specific product. However, I am facing an issue where I am unable to view the data of each individual item. Below is the code for my ...

What is the best way to connect to a library using a script within a Typescript React application?

I'm a newbie to React and haven't worked on web development in years, so I'm facing a basic issue: Currently, I'm working on implementing a Stripe-based payment flow in a React web app (written in Typescript) and I've hit a roadbl ...

Troubleshooting encoding problems when storing HTML in Mongodb

As I develop a web crawler, my next step is to store the extracted html into my MongoDB database. Here's what I have so far(using pymongo): c=urllib2.urlopen(myUrl) html=c.read() db.urls.insert( { ...

Why is it necessary to define a property outside the constructor in Typescript, when in Javascript I wouldn't have to do that?

When working with Javascript, creating a class like the one below allows us to avoid declaring and initializing a property named logs outside of the constructor: class Logger { constructor() { this.logs = []; } } However, transitioning to TypeScri ...

Remove HTML formatting from excel cells and fill separate cells

Is there a way to condense HTML code and fill different columns in Excel? For instance, If my HTML code looks like this: <p></p>10-16-2013 22:35<br/>I love pizza! Ordering was a breeze!<p></p>10-16-2013 13:19:46<br />t ...

fullpage.js supports triggering multiple onLeave and afterLoad events for different sections

I'm facing an issue while trying to incorporate multiple afterLoad and onLeave events in my fullpage.js for different sections. It seems like only the last one I set up is functional. What could be causing this problem? Interestingly, when I remove t ...

Decrease the heaviness of a Glyphicon

How can I make Glyphicons appear lighter in weight? I have utilized the "ok" Glyphicon <span class="glyphicon glyphicon-ok"></span> which currently displays as follows: Is there a method to decrease the weight of the icon in order to create a ...

Angular Lifecycle Hook - Data loading initializes after the view initialization is complete

In my component, I have loaded a firestore document and converted it into a plain js object within the constructor. However, when trying to access the field values in the template, there is a slight delay in loading them. This results in an error being dis ...

Having trouble getting Javascript to reveal hidden elements based on their class

I am having some trouble making specific fields in a form appear based on the selection made from a dropdown menu. Below is a simplified snippet of my code, which should change the display from 'none' to 'block'. Can you help me figure ...

Error message: Angular - global is not defined when using Firebase

Click here to view the error image An error occurred due to a global reference issue in the following files: Object../node_modules/firebase/auth.js (auth.js:255), webpack_require (bootstrap:81), Object../node_modules/angularfire2/auth/auth.js (ven ...

Publishing Typescript to NPM without including any JavaScript files

I want to publish my *.ts file on NPM, but it only contains type and interface definitions. There are no exported JavaScript functions or objects. Should I delete the "main": "index.js" entry in package.json and replace it with "main": "dist/types.ts" inst ...

Utilize Typescript to seamlessly transfer data between middleware stages

This is my first time creating an Express app using Typescript. I attempted to transfer data between middleware as I usually do in a JavaScript Express app In my JavaScript application, passing data was seamless What am I doing incorrectly here? Where h ...

Using jQuery's .append() method within a for loop

As a newbie in JavaScript, I've been trying to find answers to my questions, but the solutions I've come across are quite complex for my level of understanding. One specific issue I'm tackling involves creating a grid of divs using user inpu ...

Tips for aligning an element vertically when it has a float using CSS or JavaScript

I am struggling with centering the image within the article list loop I created. The code snippet looks like this: <article class="article <?php if($i%2==0) { echo 'even'; } else { echo 'odd'; } ?>"> <section class ...

Setting up CSS module class names in a Vue project using Vite js configuration

Within my vite.config.ts file, I have specified a configuration for CSS modules. return defineConfig({ ... css: { ... modules: { localsConvention: "camelCase", generateScopedName: "[name]__[local]__[hash:base64:2]" ...

Tips for providing all props to a React component while still including necessary props specified in an interface

Am I overlooking something or is this a different issue altogether? import * as React from 'react'; interface Props { value: string; } const MyComponent = (props: Props) => { const { value, ...rest } = props; return ( & ...

"Adjusting the Height of an MUI Autocomplete Input Field: A Simple Guide

I've been attempting to shrink the size of the Input field in MUI autocomplete but haven't had any luck. Here's the code I tried: styling: autocompleteStyle: { height: '2.3rem', color: `${theme.palette.grayDark1} !important ...