I created a create-react-app project on my machine.
I ran npm i @fluentui/react
in my project directory terminal to install the fluent ui package.
I have simple code to display a dropdown, with all the correct imports
import { Dropdown, DropdownMenuItemType, IDropdownStyles, IDropdownOption } from '@fluentui/react/lib/Dropdown';
const dropdownStyles: Partial<IDropdownStyles> = {
dropdown: { width: 300 },
};
const options: IDropdownOption[] = [
{ key: 'fruitsHeader', text: 'Fruits', itemType: DropdownMenuItemType.Header },
{ key: 'apple', text: 'Apple' },
{ key: 'banana', text: 'Banana' },
{ key: 'orange', text: 'Orange', disabled: true },
{ key: 'grape', text: 'Grape' },
{ key: 'divider_1', text: '-', itemType: DropdownMenuItemType.Divider },
{ key: 'vegetablesHeader', text: 'Vegetables', itemType: DropdownMenuItemType.Header },
{ key: 'broccoli', text: 'Broccoli' },
{ key: 'carrot', text: 'Carrot' },
{ key: 'lettuce', text: 'Lettuce' },
];
function App() {
return (
<div className="App">
<Dropdown
placeholder="Select an option"
options={options}
styles={dropdownStyles}
/>
</div>
);
}
What is getting displayed is a weird box with no clickable dropdown.
I did some research and I needed to import the icons so I added such code to my project.
import { initializeIcons } from "@fluentui/react/lib/Icons";
initializeIcons();
Now the dropdown displays the correct icon however nothing happens onclick of the icon.
Weirdly enough, when the screen size is tablet sized the dropdown will show up as context pane but will not appear in full screen mode
Ive searched SO and haven't found any answers to this. Any help would be appreciated!