2

Is there a way to get a selection dropdown with header items in options?

I know of course there is this tag:

<Dropdown.Header icon='tags' content='Filter by tag' />

But this requires the whole dropdown to have custom Dropdown Items and does not work with Semantic UI's "selection" keyword that does a lot of dropdown management for me and let me give the options over an object array ("options").

When adding/ declaring my options I would like to be able to define it as a header item. Like this:

{
                key: id,
                value: id,
                text: name,
                content: (
                    <span>
                        {name}
                        <Label circular>{points}</Label>
                    </span>
                ),
                header: true
            }

Is there something like that? I can't find anything in the documentation.

2 Answers 2

1

You can use a Dropdown and manipulate the array like this:

const options = [
    {
        component:
            Dropdown.Menu,
        children:
            <Dropdown.Menu scrolling>
                <Dropdown.Header content='Filter by tag' />
                <Dropdown.Divider />
            </Dropdown.Menu>,
    },
    {
        key: id,
        text: id,
        value: name
    },

]
Sign up to request clarification or add additional context in comments.

Comments

0

If you want the look of a selection dropdown coupled with the ability to use <Dropdown.Header />, try replacing selection with className='selection':

<Dropdown className='selection'>
  <Dropdown.Menu>
    <Dropdown.Header content='Header' />
    <Dropdown.Item>{'Item'}</Dropdown.Item>
  </Dropdown.Menu>
</Dropdown>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.