Angular scrollable mat-selection-list?












0















I have a question. I didnt find any familiar question on stack so i asking here, is it possible to make <mat-selection-list> scrollable (Angular 7)? I want to display scroll-bar on the right when items is too many to fit a window.



<mat-card fxFlex="33%">
<mat-selection-list>
<mat-list-item
*ngFor="let product of products"
[class.selected]="product === selectedproduct"
(click)="onSelect(product)"
>
</mat-list-item>
</mat-selection-list>











share|improve this question


















  • 1





    Can you provide sample example first?

    – Just code
    Dec 31 '18 at 12:42
















0















I have a question. I didnt find any familiar question on stack so i asking here, is it possible to make <mat-selection-list> scrollable (Angular 7)? I want to display scroll-bar on the right when items is too many to fit a window.



<mat-card fxFlex="33%">
<mat-selection-list>
<mat-list-item
*ngFor="let product of products"
[class.selected]="product === selectedproduct"
(click)="onSelect(product)"
>
</mat-list-item>
</mat-selection-list>











share|improve this question


















  • 1





    Can you provide sample example first?

    – Just code
    Dec 31 '18 at 12:42














0












0








0








I have a question. I didnt find any familiar question on stack so i asking here, is it possible to make <mat-selection-list> scrollable (Angular 7)? I want to display scroll-bar on the right when items is too many to fit a window.



<mat-card fxFlex="33%">
<mat-selection-list>
<mat-list-item
*ngFor="let product of products"
[class.selected]="product === selectedproduct"
(click)="onSelect(product)"
>
</mat-list-item>
</mat-selection-list>











share|improve this question














I have a question. I didnt find any familiar question on stack so i asking here, is it possible to make <mat-selection-list> scrollable (Angular 7)? I want to display scroll-bar on the right when items is too many to fit a window.



<mat-card fxFlex="33%">
<mat-selection-list>
<mat-list-item
*ngFor="let product of products"
[class.selected]="product === selectedproduct"
(click)="onSelect(product)"
>
</mat-list-item>
</mat-selection-list>








angular angular-material angular-material2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 31 '18 at 12:39









michasaucermichasaucer

28317




28317








  • 1





    Can you provide sample example first?

    – Just code
    Dec 31 '18 at 12:42














  • 1





    Can you provide sample example first?

    – Just code
    Dec 31 '18 at 12:42








1




1





Can you provide sample example first?

– Just code
Dec 31 '18 at 12:42





Can you provide sample example first?

– Just code
Dec 31 '18 at 12:42












3 Answers
3






active

oldest

votes


















1














Simple CSS



mat-selection-list {
max-height: 400px;
overflow: auto;
}


StackBlitz Demo






share|improve this answer
























  • It works! thanks.

    – michasaucer
    Dec 31 '18 at 13:27



















1














You can try with:



<mat-card fxFlex="33%">
<mat-selection-list [style.overflow]="'auto'" [style.height.px]="'300'">
<mat-list-item
*ngFor="let product of products"
[class.selected]="product === selectedproduct"
(click)="onSelect(product)">
</mat-list-item>
</mat-selection-list>





share|improve this answer































    0














    By setting custom CSS properties?



    CSS for fancy scroll bar which only supports Chrome browsers:



    .custom-scroll-bar{
    height:70vh;
    overflow-y:scroll;
    overflow-x: hidden;
    }

    .custom-scroll-bar::-webkit-scrollbar{
    width: 5px;
    }

    .custom-scroll-bar::-webkit-scrollbar-thumb{
    background: rgba(0,0,0,.26);
    }


    For Firefox and Internet explorer just simply use:



    .custom-scroll-bar{
    height:70vh;
    overflow-y:scroll;
    }


    HTML:



    <mat-selection-list #shoes class="custom-scroll-bar">
    <mat-list-option *ngFor="let shoe of typesOfShoes">
    {{shoe}}
    </mat-list-option>
    </mat-selection-list>


    StackBlitz Example






    share|improve this answer





















    • 2





      -webkit-scrollbar works only on Chrome.

      – Oen44
      Dec 31 '18 at 12:59











    • you got it right!

      – Prashant Pimpale
      Dec 31 '18 at 13:21











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53987643%2fangular-scrollable-mat-selection-list%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Simple CSS



    mat-selection-list {
    max-height: 400px;
    overflow: auto;
    }


    StackBlitz Demo






    share|improve this answer
























    • It works! thanks.

      – michasaucer
      Dec 31 '18 at 13:27
















    1














    Simple CSS



    mat-selection-list {
    max-height: 400px;
    overflow: auto;
    }


    StackBlitz Demo






    share|improve this answer
























    • It works! thanks.

      – michasaucer
      Dec 31 '18 at 13:27














    1












    1








    1







    Simple CSS



    mat-selection-list {
    max-height: 400px;
    overflow: auto;
    }


    StackBlitz Demo






    share|improve this answer













    Simple CSS



    mat-selection-list {
    max-height: 400px;
    overflow: auto;
    }


    StackBlitz Demo







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 31 '18 at 12:55









    Oen44Oen44

    1,8001818




    1,8001818













    • It works! thanks.

      – michasaucer
      Dec 31 '18 at 13:27



















    • It works! thanks.

      – michasaucer
      Dec 31 '18 at 13:27

















    It works! thanks.

    – michasaucer
    Dec 31 '18 at 13:27





    It works! thanks.

    – michasaucer
    Dec 31 '18 at 13:27













    1














    You can try with:



    <mat-card fxFlex="33%">
    <mat-selection-list [style.overflow]="'auto'" [style.height.px]="'300'">
    <mat-list-item
    *ngFor="let product of products"
    [class.selected]="product === selectedproduct"
    (click)="onSelect(product)">
    </mat-list-item>
    </mat-selection-list>





    share|improve this answer




























      1














      You can try with:



      <mat-card fxFlex="33%">
      <mat-selection-list [style.overflow]="'auto'" [style.height.px]="'300'">
      <mat-list-item
      *ngFor="let product of products"
      [class.selected]="product === selectedproduct"
      (click)="onSelect(product)">
      </mat-list-item>
      </mat-selection-list>





      share|improve this answer


























        1












        1








        1







        You can try with:



        <mat-card fxFlex="33%">
        <mat-selection-list [style.overflow]="'auto'" [style.height.px]="'300'">
        <mat-list-item
        *ngFor="let product of products"
        [class.selected]="product === selectedproduct"
        (click)="onSelect(product)">
        </mat-list-item>
        </mat-selection-list>





        share|improve this answer













        You can try with:



        <mat-card fxFlex="33%">
        <mat-selection-list [style.overflow]="'auto'" [style.height.px]="'300'">
        <mat-list-item
        *ngFor="let product of products"
        [class.selected]="product === selectedproduct"
        (click)="onSelect(product)">
        </mat-list-item>
        </mat-selection-list>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 31 '18 at 12:48









        jaasojaaso

        69937




        69937























            0














            By setting custom CSS properties?



            CSS for fancy scroll bar which only supports Chrome browsers:



            .custom-scroll-bar{
            height:70vh;
            overflow-y:scroll;
            overflow-x: hidden;
            }

            .custom-scroll-bar::-webkit-scrollbar{
            width: 5px;
            }

            .custom-scroll-bar::-webkit-scrollbar-thumb{
            background: rgba(0,0,0,.26);
            }


            For Firefox and Internet explorer just simply use:



            .custom-scroll-bar{
            height:70vh;
            overflow-y:scroll;
            }


            HTML:



            <mat-selection-list #shoes class="custom-scroll-bar">
            <mat-list-option *ngFor="let shoe of typesOfShoes">
            {{shoe}}
            </mat-list-option>
            </mat-selection-list>


            StackBlitz Example






            share|improve this answer





















            • 2





              -webkit-scrollbar works only on Chrome.

              – Oen44
              Dec 31 '18 at 12:59











            • you got it right!

              – Prashant Pimpale
              Dec 31 '18 at 13:21
















            0














            By setting custom CSS properties?



            CSS for fancy scroll bar which only supports Chrome browsers:



            .custom-scroll-bar{
            height:70vh;
            overflow-y:scroll;
            overflow-x: hidden;
            }

            .custom-scroll-bar::-webkit-scrollbar{
            width: 5px;
            }

            .custom-scroll-bar::-webkit-scrollbar-thumb{
            background: rgba(0,0,0,.26);
            }


            For Firefox and Internet explorer just simply use:



            .custom-scroll-bar{
            height:70vh;
            overflow-y:scroll;
            }


            HTML:



            <mat-selection-list #shoes class="custom-scroll-bar">
            <mat-list-option *ngFor="let shoe of typesOfShoes">
            {{shoe}}
            </mat-list-option>
            </mat-selection-list>


            StackBlitz Example






            share|improve this answer





















            • 2





              -webkit-scrollbar works only on Chrome.

              – Oen44
              Dec 31 '18 at 12:59











            • you got it right!

              – Prashant Pimpale
              Dec 31 '18 at 13:21














            0












            0








            0







            By setting custom CSS properties?



            CSS for fancy scroll bar which only supports Chrome browsers:



            .custom-scroll-bar{
            height:70vh;
            overflow-y:scroll;
            overflow-x: hidden;
            }

            .custom-scroll-bar::-webkit-scrollbar{
            width: 5px;
            }

            .custom-scroll-bar::-webkit-scrollbar-thumb{
            background: rgba(0,0,0,.26);
            }


            For Firefox and Internet explorer just simply use:



            .custom-scroll-bar{
            height:70vh;
            overflow-y:scroll;
            }


            HTML:



            <mat-selection-list #shoes class="custom-scroll-bar">
            <mat-list-option *ngFor="let shoe of typesOfShoes">
            {{shoe}}
            </mat-list-option>
            </mat-selection-list>


            StackBlitz Example






            share|improve this answer















            By setting custom CSS properties?



            CSS for fancy scroll bar which only supports Chrome browsers:



            .custom-scroll-bar{
            height:70vh;
            overflow-y:scroll;
            overflow-x: hidden;
            }

            .custom-scroll-bar::-webkit-scrollbar{
            width: 5px;
            }

            .custom-scroll-bar::-webkit-scrollbar-thumb{
            background: rgba(0,0,0,.26);
            }


            For Firefox and Internet explorer just simply use:



            .custom-scroll-bar{
            height:70vh;
            overflow-y:scroll;
            }


            HTML:



            <mat-selection-list #shoes class="custom-scroll-bar">
            <mat-list-option *ngFor="let shoe of typesOfShoes">
            {{shoe}}
            </mat-list-option>
            </mat-selection-list>


            StackBlitz Example







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 31 '18 at 13:33

























            answered Dec 31 '18 at 12:51









            Prashant PimpalePrashant Pimpale

            3,3423830




            3,3423830








            • 2





              -webkit-scrollbar works only on Chrome.

              – Oen44
              Dec 31 '18 at 12:59











            • you got it right!

              – Prashant Pimpale
              Dec 31 '18 at 13:21














            • 2





              -webkit-scrollbar works only on Chrome.

              – Oen44
              Dec 31 '18 at 12:59











            • you got it right!

              – Prashant Pimpale
              Dec 31 '18 at 13:21








            2




            2





            -webkit-scrollbar works only on Chrome.

            – Oen44
            Dec 31 '18 at 12:59





            -webkit-scrollbar works only on Chrome.

            – Oen44
            Dec 31 '18 at 12:59













            you got it right!

            – Prashant Pimpale
            Dec 31 '18 at 13:21





            you got it right!

            – Prashant Pimpale
            Dec 31 '18 at 13:21


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53987643%2fangular-scrollable-mat-selection-list%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas