Skip to content

Best Practice to control height of <Dropdown/> & <ComboBox/> options list? #33266

Answered by pradeept95
Patchrik asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Patchrik ,

You can override listbox slot to change the popover behavior in Dropdown or ComboBox. Here is an example of how you can control maxHeight of listbox.

https://stackblitz.com/edit/3myzr1?file=src%2Fexample.tsx

import * as React from 'react';
import {
  Dropdown,
  makeStyles,
  Option,
  useId,
} from '@fluentui/react-components';
const useStyles = makeStyles({
  root: {
    // Stack the label above the field with a gap
    display: 'grid',
    gridTemplateRows: 'repeat(1fr)',
    justifyItems: 'start',
    gap: '2px',
    maxWidth: '400px',
  },

  listbox: {
    height: '100px',
  },
});

const options = [
  'Cat',
  'Caterpillar',
  'Corgi',
  'Chupacabra',
  'Dog',
  'Fer…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Patchrik
Comment options

Answer selected by Patchrik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants