I'm trying to add arrows on matTooltip, there is any way to add arrows on matTooltip.
<button mat-raised-button
matTooltip="Info about the action"
aria-label="Button that displays a tooltip when focused or hovered over">
Action
</button>
Tooltip Arrows To create an arrow that should appear from a specific side of the tooltip, add "empty" content after tooltip, with the pseudo-element class ::after together with the content property. The arrow itself is created using borders. This will make the tooltip look like a speech bubble.
matTooltip is used when certain information is to be displayed when a user hovers on a button. Approach: First, install the angular material using the above-mentioned command. After completing the installation, Import 'MatTooltipModule' from '@angular/material/tooltip' in the app.
By default tooltip is displayed below the element. we can change the tooltip position by using matTooltipPosition input property.
The Angular Material tooltip provides a text label that is displayed when the user hovers over or longpresses an element.
You need to override material styles. and add before/after pseudo-element as arrow. For example if you need to style a tooltip with left border and arrow just do something like that
.mat-tooltip {
// to make possible place arrow pseudo element outside tooltip with absolute positioning
overflow: visible;
position: relative;
&.right {
border-left: 6px solid red;
margin-left: 5px;
&::before {
position: absolute;
content: '';
display: inline-block;
background-color: red;
clip-path: polygon(50% 0, 0 50%, 50% 100%);
left: -12px;
width: 15px;
height: 15px;
top: 50%;
transform: translateY(-50%);
}
}
}
Following the usage of Material Design, arrows are not included in angular tooltip component. Here you could take a look what you can do and not to do with tooltips https://material.io/components/tooltips/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With