Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement option group in semantic-ui dropdown select

I want to show categories and sub categories in a dropdown similar to select with option group in html.

How should I do it in semantic-ui. I didn't find any help on it.

like image 813
Natwar Singh Avatar asked Mar 19 '23 07:03

Natwar Singh


1 Answers

I don't know if you still need this since the question is a bit old but I found this Fiddle.

Basically you would use div instead of select and option.

HTML

<div class="ui selection dropdown multiple search optgroup">
    <div class="text">Select</div>
    <i class="dropdown icon"></i>
    <div class="menu">
        <div class="ui horizontal divider">Optgroup 1</div>
        <div class="item">Option 1</div>
        <div class="item">Option 2</div>
        <div class="ui horizontal divider">Optgroup 2</div>
        <div class="item">Option 3</div>
        <div class="item">Option 4</div>
    </div>
</div

CSS

.dropdown.optgroup .divider {
    border-top: none !important;
}

Jquery

$('.ui.dropdown').dropdown();
like image 198
Patrick Gregorio Avatar answered Apr 09 '23 16:04

Patrick Gregorio