Tips for maintaining visibility of the selected option within a dropdown menu

When I choose one item from a dropdown list of 3, the selected item is still visible in the dropdown along with the other two. I would like all three items to be displayed even if one is selected.

reference dropdown Based on the reference image, even though "polo shirt" is selected, I want it to remain visible in the dropdown menu with a different background to indicate it has been chosen.

Answer №1

If you want to display selected items in your dropdown, set the hideSelectedOptions={false} prop on your selector.

Check out this example below:

const choices = [
  { id: "shirt", name: "T-shirt" },
  { id: "pants", name: "Pants" },
  { id: "jacket", name: "Jacket" },
];

export const DisplayChoices = () => {
  return <Dropdown options={choices} isMultiple hideSelectedOptions={false} />;
};

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implement variable tailwind styling in a react component using Next.JS, Tailwind, and TypeScript

Having some difficulty assigning dynamically tailwind classes to a react component. The theme colors have been extended in the tailwind.config.js file as shown below: ... theme: { extend: { colors: { blueGray: { 50: '#f6 ...

I am having trouble getting my CSS styles to apply to nested components within Bootstrap React components

Currently I am learning react and in the process of creating a website using react-bootstrap. While working on my navbar, I encountered an issue where I was unable to change the font and font-color of the navbar items. The CSS that I applied only affected ...

AgGrid's magical dropdown feature

Struggling to integrate a bootstrap-4 dropdown menu with AgGrid, I'm facing an issue where the data table overlaps the dropdown when the html is present. Attempts to increase the z-index have not yielded results. Below is the html code snippet: < ...

I'm curious about how to test a method call within a component using Enzyme and Mocha - can

Having trouble testing a component method using enzyme, mocha, and sinon. Need to verify if the component triggers the loadPosts method on button click. import React from 'react'; import { configure, mount} from 'enzyme'; import { ex ...

Using ReactJS: Injecting components and passing variables in extended components without the need for functions

Currently, I am utilizing apollo for the authentication process in my nextJS application. My next task is to incorporate i18n support, but I am encountering some fundamental issues: The primary obstacle lies in handling class Index extends React.Component ...

Ways to reduce the size of images within a bootstrap carousel

I'm currently working on creating a carousel that will serve as a background image cover for my website, similar to the revolutionary slider in WordPress but without using a plugin. I am developing it specifically for my static website. The challenge ...

Choose the initial p tag that includes an image, based on the content of another div

I am trying to figure out how to manipulate the code on my website: <div class="the-post-thumbnail"> <img src="" alt="" width="" height="" /> </div> <div class="post-body"> <p><img src="" alt="" width="" height="" ...

Returning to the previous page is done by navigating back using the previous URL in Next.js

Recently, I encountered a situation where I had implemented filters on a webpage. Upon applying the filters, the URL of the page would change and additional query strings would be appended to the end. This caused an issue when navigating back using the b ...

What is the best way to assign names to images in a Rails application?

When working in html, you can use the code <img class="myimage" src="image.jpg"> to make editing in .css simpler. But what is the equivalent of this when dealing with a .html.erb file? For example, where should I define the class in this <%= imag ...

What does the error message "Uncaught TypeError: Cannot access property 'style' of an undefined object" mean?

I've been attempting to execute the code below, but I keep encountering an error. I even tried including document.addEventListener('DOMContentLoaded', (event) => yet it still doesn't work. Interestingly, there are no errors if I run ...

Bootstrap 4: Arrange input fields in a horizontal layout

I'm a newbie when it comes to Bootstrap 4 and could use some guidance. I'm looking to have my first two input fields aligned horizontally on the same line, instead of stacked on top of each other. Something like this: check out the image here B ...

Creating a Horizontal Divider with Text in ReactLearn how to create a stylish horizontal

Struggling to create a React component for a Horizontal Divider with text in between. Online resources have been of no help so far. Attempted using material-ui Divider like this: <Divider>Or</Divider> However, encountered the following error: ...

The HTML code does not seem to be acknowledging the CakePHP link

When using Cakephp to generate a link with Html->link, the code looks like this: echo $this->Html->link('Download',array( 'plugin'=> 'galleries', 'controller'=> 'galleries', 'a ...

Different ways to utilize a React hook within a React useCallback

In my next.js React application, I have a section called "Banners" where I am currently in the process of building a "store" using the Context API. However, when I try to use the "useFetchBanners" function within my page to set the initial state, I encount ...

How can you ensure that an element returns to its original position after being animated in jQuery?

I want to add some animations to my website using jQuery, but I lack the skills to create them from scratch. I have managed to copy some code snippets, but I am facing an issue with one of my animations. When I click a button, the block animates, but I wan ...

Parenting and Child Components: Keeping the State in Sync

I am currently diving into my initial React project which focuses on a basic expense tracker for credit cards. While I'm still in the learning phase, I hope you can decipher the intent behind my code. My current roadblock involves mapping the state an ...

Aligning text vertically within an HTML <a> tag block

Calling all CSS experts! I'm struggling with aligning text to the bottom of a block element with a fixed width and height that contains a background image and a title. I've tried using display: table-cell; and vertical-align: bottom; without succ ...

Troubleshooting the Discrepancy Between console.log Array and ReactJS State

I am currently working on a CompanyAddress component that deals with the addresses of companies. Each address is represented as an object with two fields: address and metro. class CompanyAddress extends React.Component<Props, State> { constructo ...

How can one properly execute a DELETE request in the NextJS 13.4 API using the latest App Router with Response, NextAPIResponse, and NextResponse?

How can a simple DELETE be properly executed in NextJS 13.4 using the new App Router? The traditional method of performing a delete operation involved utilizing NextAPIRequest, NextAPIResponse, checking for the 'DELETE' method with if (req.metho ...

Troubleshooting: Issues with CSS fixed positioning

Whenever I try to scroll down, my navbar moves along with the page. Even when I resize the window, it keeps shifting despite using position:fixed. What mistake am I making? nav li:nth-child(1) { position: fixed; border: 1px solid #15317E; font-si ...