Skip to content

experiment: add virtual-list base styles #9668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions dev/virtual-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
root.innerHTML = `<div>${item.label}</div>`;
};

const list = document.querySelector('vaadin-virtual-list');
list.items = items;
list.renderer = renderer;
document.querySelectorAll('vaadin-virtual-list').forEach((list) => {
list.items = items;
list.renderer = renderer;
});
</script>
</head>

<body>
<vaadin-virtual-list style="height: 400px"></vaadin-virtual-list>
<section>
<vaadin-virtual-list style="height: 200px"></vaadin-virtual-list>
</section>
<section>
<h2 class="heading">Overflow Indicators</h2>
<vaadin-virtual-list style="height: 200px" theme="overflow-indicators"></vaadin-virtual-list>
</section>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @license
* Copyright (c) 2017 - 2025 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import type { CSSResult } from 'lit';

export const virtualListStyles: CSSResult;
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @license
* Copyright (c) 2017 - 2025 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import '@vaadin/component-base/src/style-props.js';
import { css } from 'lit';

export const virtualListStyles = css`
:host {
display: block;
height: 400px;
overflow: auto;
flex: auto;
align-self: stretch;
}

:host([hidden]) {
display: none !important;
}

:host(:not([grid])) #items > ::slotted(*) {
width: 100%;
}

#items {
position: relative;
}

:host([theme~='overflow-indicators'])::before,
:host([theme~='overflow-indicators'])::after {
content: '';
display: none;
position: sticky;
inset: 0;
z-index: 9999;
height: 1px;
margin-bottom: -1px;
background: var(--vaadin-virtual-list-border-color, var(--vaadin-border-color));
}

:host([theme~='overflow-indicators'])::after {
margin-bottom: 0;
margin-top: -1px;
}

:host([theme~='overflow-indicators'][overflow~='top'])::before,
:host([theme~='overflow-indicators'][overflow~='bottom'])::after {
display: block;
}
`;