What exactly inset does in angular material mat-divider?

Viewed 822

One of the mat-divider attributes in Angular Material is inset an Input that takes a boolean. In the documentation, it refers to it as follows:

enter image description here

Whether the divider is an inset divider.

But it does not define it properly, so I wondered what it precisely does if we set it to true.

1 Answers

mat-divider inset attribute

As you know, it is an @Input() of the mat-divider component that takes a boolean as a value. Mat divider draws a line (it can be horizontally or vertically with vertical @Input), and if we set the inset to true, all it does is to try and wrap the line with the elements beside it.

If you inspect the elements, you do realize that two properties may be applied to the element:

  • position: static
  • margin: 80px (it could be applied on the left, right, or both)

In the two following images, you can find out how setting inset to true or false differs from each other.

enter image description here

As you can see, in the left image, the mat-divider has a position of static, but on the other hand, on the right image, there are no spaces between the line and the edges of the component (here a mat-card component)


Let's check another good example together regarding inset functionality:

enter image description here

As it is clear, there is a space on the left side of the divider (margin-left: '80px').

I have provided some codes in StackBlitz here, which you can check more.

Related