skip to Main Content

I am using Angular 15, Angular Material 14 and CSS

I have almost finished my work in this sample..

I am using -webkit-scrollbar from this link – Orangeable Scrollbars

The code used is as below…

<mat-select disableOptionCentering (selectionChange)="validateInputs(userForm)" formControlName="siteId" placeholder="Select Site ID" panelClass="custom-panel-siteId">

.custom-panel-siteId {
  margin: 40px 0px !important;
  min-width: 313px !important;
  margin-left: 17px !important;
  border-radius: 5px;
}

.custom-panel-siteId::-webkit-scrollbar {
  border-radius: 5px;
}

.custom-panel-siteId::-webkit-scrollbar-track {
  border-radius: 5px;
  background-color: rgba(242, 242, 242);
}

.custom-panel-siteId::-webkit-scrollbar-thumb {
  border-radius: 5px;
  background-color: rgba(211, 211, 211);
}

The output comes like this…

Just I need to add Down and Up arrows for the scrollbar.

How can I achieve this?

Scrollbar

2

Answers


  1. HTML

    <mat-select
            name="countryString"
            [(value)]="selectedCountry"
            placeholder="Country"
          >
            <mat-option *ngFor="let data of countries" [value]="data.full">{{
              data.full
            }}</mat-option>
          </mat-select>
    

    TS

    export class AppComponent {
      constructor() {}
    
      countries: any = [
        {
          full: 'Great Britain',
          short: 'GB',
        },
        {
          full: 'United States',
          short: 'US',
        },
        {
          full: 'Canada',
          short: 'CA',
        },
        {
          full: 'asas',
          short: 'GB',
        },
        {
          full: 'United States',
          short: 'US',
        },
        {
          full: 'Canada',
          short: 'CA',
        },
      ];
      selectedCountry: string = 'GB';
    
      selectedCountryControl = new FormControl(this.selectedCountry);
    }
    

    Mat-select by default add up and down arrow

    https://prnt.sc/QxbmuP1eTzj5

    Login or Signup to reply.
  2. After looking at this codepen I finally got the proper scrollbar for fixing this issue!

    css

    .custom-panel-siteId {
      margin: 40px 0px !important;
      min-width: 313px !important;
      margin-left: 17px !important;
      border-radius: 5px !important;
    }
    
    .custom-panel-siteId::-webkit-scrollbar {
      width: 20px;
      height: 12px;
      background-color: #f1f1f1;
      border-radius: 5px;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb {
      border-radius: 1px;
      background-color: #c1c1c1;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb:hover {
      background-color: #a8a8a8;
      border-radius: 5px;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb:horizontal {
      border-top: 2px solid #f1f1f1;
      border-bottom: 2px solid #f1f1f1;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb:vertical {
      border-left: 2px solid #f1f1f1;
      border-right: 2px solid #f1f1f1;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb:active {
      background-color: #787878;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-track-piece {
    }
    
    .custom-panel-siteId::-webkit-scrollbar-track {
      background-color: #f1f1f1;
      border-radius: 5px;
    }
    
    /* Buttons */
    .custom-panel-siteId::-webkit-scrollbar-button {
      background-color: #f1f1f1;
      background-repeat: no-repeat;
      background-size: 7px;
      background-position: center;
      height: 17px;
      width: 17px;
      border-radius: 5px;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:disabled {
      /* Why is this not red??? */
      background-color: red;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:hover {
      background-color: #d2d2d2;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:active {
      background-color: #787878;
    }
    
    /* Up */
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:decrement {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23505050'><polygon points='50,30 100,80 0,80'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:decrement:active {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23FFFFFF'><polygon points='50,30 100,80 0,80'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:decrement:hover {
      border-color: transparent transparent #505050 transparent;
    }
    
    /* Down */
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:increment {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23505050'><polygon points='0,15 100,15 50,75'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:increment:hover {
      border-color: #505050 transparent transparent transparent;
    }
    
    /* Left */
    .custom-panel-siteId::-webkit-scrollbar-button:horizontal:decrement {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23505050'><polygon points='15,50 75,100 75,0'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:horizontal:decrement:hover {
      border-color: transparent #505050 transparent transparent;
    }
    
    /* Right */
    .custom-panel-siteId::-webkit-scrollbar-button:horizontal:increment {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23505050'><polygon points='15,0 15,100 75,50'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:horizontal:increment:hover {
      border-color: transparent transparent transparent #505050;
    }
    

    stackblitz

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search