search

Home  >  Q&A  >  body text

Angular 16: How do I change the size of an Angular Material checkbox (MDC)?

<p>In Material, which is now considered legacy, I can set the size of the checkbox as follows: </p> <pre class="brush:php;toolbar:false;">.mat-checkbox-frame { width: 1.5rem; }</pre> <p>How can I achieve the same effect in MDC? </p>
P粉254077747P粉254077747464 days ago442

reply all(1)I'll reply

  • P粉092778585

    P粉0927785852023-08-19 11:02:21

    To change the size of the checkbox, add the following CSS code in styles.scss:

    .mdc-checkbox__background {
      width: 1.5rem !important;
      height: 1.5rem !important;
    }

    However, if you want to use the default ripple effect, this is only half the solution. Now you also need to align the checkbox so that it fits perfectly within the circle of the ripple effect. Please add the following CSS code in styles.scss:

    .mdc-checkbox__background {
      width: 1.5rem !important;
      height: 1.5rem !important;
      top: 50% !important; /* 添加 */
      left: 50% !important; /* 添加 */
      transform: translate(-50%, -50%) !important; /* 添加 */
    }

    Please refer to Real-time Demonstration.

    reply
    0
  • Cancelreply