Skip to content

Commit f97d916

Browse files
authored
refactor: register base color CSS variables as <color> explicitly (#10493)
1 parent e71c6d3 commit f97d916

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/component-base/src/styles/style-props.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@
66
import { css } from 'lit';
77
import { addGlobalThemeStyles } from '@vaadin/vaadin-themable-mixin/register-styles.js';
88

9+
// NOTE: Base color CSS custom properties are explicitly registered as `<color>`
10+
// here to avoid performance issues in Aura. Aura overrides these properties with
11+
// values that use complex, nested relative color functions, and without explicit
12+
// typing, Chrome 142 was found to render components that use them roughly 40% slower.
13+
[
14+
'--vaadin-text-color',
15+
'--vaadin-text-color-disabled',
16+
'--vaadin-text-color-secondary',
17+
'--vaadin-border-color',
18+
'--vaadin-border-color-secondary',
19+
'--vaadin-background-color',
20+
].forEach((propertyName) => {
21+
CSS.registerProperty({
22+
name: propertyName,
23+
syntax: '<color>',
24+
inherits: true,
25+
// Use this initial value so the color stays visible when the property
26+
// is set to an invalid value to make debugging a bit easier.
27+
initialValue: 'light-dark(black, white)',
28+
});
29+
});
30+
931
addGlobalThemeStyles(
1032
'vaadin-base',
1133
css`

0 commit comments

Comments
 (0)