I am using Office UI Fabric React that comes with SPFx. It's version 6.214.0. I have a dropdown that looks like this:
<Dropdown placeholder={strings.Position} label="" options={positionOptions} onChange={(e, option) => setPosition(option.text)} styles = {dropdownStyles} className={styles.dropDown}/>
The styles.dropDown has the following styles:
.dropDown{
float: left;
margin-right: 15px;
}
The values are filled dynamically based on a web service. However the dropdown width doesn't fit the items inside.
If I remove the float left, all of them will take 100% of the width.
How do we achieve this with UI Fabric React?

I would recommend using the
stylesprop. You can style therootof the component as well as individual aspects of the output like the callout, thedropdownItem, thelabeland more. A lot of Fluent UI / office-ui-fabric-react components have thisstylesprop - they give you clearly defined elements that you can override style settings for.Your
floatmay actually be contributing to this issue. A float takes an element out of the normal flow of rendering - and might be screwing with the Dropdown component's ability to size its callout based on the widths of its children. You can read about what float actually does on the MDN Web Docs.In the first instance I would suggest removing your
float: leftstatement and seeing if that improves things. If that doesn't work I would try applying aminWidthto one of the available keys in thestylesprop - perhaps thedropdownItemelement.