css - Angular (18) Material Tooltip - how to addcustomize border? - Stack Overflow

I am using the latest version of Angular and Material, as of this question's publishment.I'v

I am using the latest version of Angular and Material, as of this question's publishment.

I've managed to change the background and text color of the tooltip, overriding these variables:

--mdc-plain-tooltip-container-color: white !important;
//--mdc-plain-tooltip-container-border: 1px solid blue !important;
--mdc-plain-tooltip-supporting-text-color: var(--logo-blue) !important;

(The commented line is an attempt to follow the same logic, but with no luck)

But failed to find a way to apply a simple border to it.

I even got into the source files of the Material library and didn't find any CSS for that anywhere.

Unfortunately I cannot even check the elements in the DOM for this tooltip, because it disappears when I hover off of it.

Would appreciate to know of a way to add the border to the Material tooltip element...

I am using the latest version of Angular and Material, as of this question's publishment.

I've managed to change the background and text color of the tooltip, overriding these variables:

--mdc-plain-tooltip-container-color: white !important;
//--mdc-plain-tooltip-container-border: 1px solid blue !important;
--mdc-plain-tooltip-supporting-text-color: var(--logo-blue) !important;

(The commented line is an attempt to follow the same logic, but with no luck)

But failed to find a way to apply a simple border to it.

I even got into the source files of the Material library and didn't find any CSS for that anywhere.

Unfortunately I cannot even check the elements in the DOM for this tooltip, because it disappears when I hover off of it.

Would appreciate to know of a way to add the border to the Material tooltip element...

Share Improve this question asked Nov 16, 2024 at 17:48 TheCuBeManTheCuBeMan 2,5034 gold badges27 silver badges41 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

There is no css variable for setting border because the border styling is not present. I can only see border-radius property CSS variable.

So you have to define the CSS manually, like shown below.

.mat-mdc-tooltip-surface {
  --mdc-plain-tooltip-container-color: white !important;
  //--mdc-plain-tooltip-container-border: 1px solid blue !important;
  --mdc-plain-tooltip-supporting-text-color: var(--logo-blue) !important;
  border: 1px solid black;
}

Stackblitz Demo


To debug such scenarios, you have to have the chrome debugger open in the same tab as your app, then go to sources tab and keep it open. Hover over the item to show the tooltip and press F8 key this will trigger a breakpoint and the hover will also be visible, now you can simply use the element inspector and inspect the CSS for the tooltip.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745648326a4638105.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信