Skip to content

feat: grid base style borders and row colors - #10190

Closed
jouni wants to merge 21 commits into
mainfrom
fix/grid-base-styles
Closed

jouni wants to merge 21 commits into
mainfrom
fix/grid-base-styles

Conversation

@jouni

@jouni jouni commented Sep 17, 2025 •

Copy link
Copy Markdown
Member

This change adds a few different custom properties to grid base styles, to easily style various row states:

  • --vaadin-grid-row-odd-background-color: set this globally to have alternating row colors on all grids. Needs to be a solid/opaque color.
  • --vaadin-grid-row-selected-background-color: background color for selected rows. Can be semi-transparent.
  • --vaadin-grid-row-highlight-background-color: optional highlight color for rows, intended to be used together with cellPartNameGenerator. Can be semi-transparent.
  • --vaadin-grid-row-hover-background-color: background color for hovered rows. Can be semi-transparent.

This change also changes how the row borders are rendered together with all the mentioned states.

The previous --vaadin-grid-cell-border-width property is now divided into separate --vaadin-grid-column-border-width and --vaadin-grid-row-border-width properties, which can be used to set the default borders on all grids. The built-in no-row-borders and column-borders variants are removed, to be left for themes to add if needed.

@jouni
jouni force-pushed the fix/grid-base-styles branch from c71d635 to 26e60ed Compare September 17, 2025 12:14
@web-padawan

Copy link
Copy Markdown
Member

Updated screenshots for grid-pro and CRUD components, please verify them as there are some small changes.

@jouni

jouni commented Sep 18, 2025

Copy link
Copy Markdown
Member Author

Yeah, thanks. I noticed some remaining issues, currently working on addressing those. I’ll update the screenshots after that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change in the CRUD screenshots is the border after the last/only item row.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't mean to push this screenshot update. I’m not sure what’s going on, maybe some timing issue? The hover style appears as it should locally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a closer look.

Something seems wrong with the editable-cell-focus too - the outline in thew new screenshot seems a bit clipped on top, could you please confirm if that is expected?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be related to the fact that on MacOS, we use "focus button mode" for cells and on Windows, it's not used. Try commenting out this line and then you will see the problem:

this._focusButtonMode = navigator.platform.includes('Mac');

@jouni
jouni force-pushed the fix/grid-base-styles branch from 04fdcd0 to b277f6e Compare September 20, 2025 19:24
@sonarqubecloud

Copy link
Copy Markdown

@jouni
jouni marked this pull request as draft September 22, 2025 07:36
@jouni

jouni commented Sep 22, 2025

Copy link
Copy Markdown
Member Author

I’ll work on splitting this up to separate PRs. I think I should be able to split out the following changes:

  • Row colors/highlights & fixing Grid Pro "highlight-read-only" variant
  • Update how row borders are rendered (separate custom props for row and column borders)
  • Refactor (and fix) keyboard focus outline implementation

Comment thread dev/grid.html

// Theme Controls
const themeControls = ['no-border', 'no-row-borders', 'column-borders', 'row-stripes', 'wrap-cell-content'];
const themeControls = [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now when #10198 is merged, this change needs to be applied to dev/playground/grid.html instead.

}

:host([navigating]) {
:is([part~='row'], [part~='cell']):is(:focus, :focus-within :focus-visible) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This combination of :focus, :focus-within :focus-visible is somewhat unclear, is it needed specifically for the focus button mode? Maybe could add a comment clarifying it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll re-evaluate this once I get to redoing this in a separate PR. This is the result of me just trying to brute-force the visual tests to pass, without thinking clearly about the behavior or how the implementation works internally.

I think there are some differences between Safari and other browsers regarding focus behavior. Other browsers seem to respect :focus-visible more reliable, whereas in Safari I need to use :host([navigating]) :focus instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants