Blazor 드롭다운 목록 구성 요소 - 개요

    풍부한 기능을 갖춘 Blazor 드롭다운 목록은 기본 필터링, 접근성, 사전 선택된 값, 유연한 데이터 바인딩, 그룹화, UI 사용자 지정 등을 제공합니다. 이 구성 요소가 실제로 하는 일은 HTML 선택 태그를 효과적이고 쉽게 대체하여 사용자가 미리 정의된 여러 옵션 세트에서 편집할 수 없는 값을 빠르게 선택할 수 있도록 하는 것입니다.

    Ignite UI for Blazor는 미리 정의된 값의 토글 목록을 표시하고 사용자가 클릭 한 번으로 단일 옵션 항목을 쉽게 선택할 수 있도록 합니다. Blazor 드롭다운 메뉴로 작동하도록 빠르게 구성하거나 데이터를 그룹화하여 더 유용한 시각적 정보를 제공하는 데 사용할 수 있습니다. 또한 그룹화를 사용하면 플랫 및 계층적 데이터를 모두 사용할 수 있습니다.

    당사의 컴포넌트를 사용하면 프로젝트에 필요한 모든 기능과 사용자 정의 옵션(스타일 사용자 정의, Blazor 드롭다운 배치 옵션, 템플릿, 헤더, 푸터, 본문, 목록 등에 표시되는 내용과 방법을 변경하는 기능 등)을 얻을 수 있습니다.

    Blazor Dropdown Example

    다음 Blazor 드롭다운 목록 예제는 선택할 수 있는 세 가지 기본 옵션과 함께 간단한 대화형 Blazor 드롭다운 메뉴의 작동 방식을 보여줍니다. 작동 방식을 확인하세요.

    How to use the Dropdown List with Ignite UI for Blazor

    Before using the IgbDropdown, you need to register it as follows:

    // in Program.cs file
    
    builder.Services.AddIgniteUIBlazor(typeof(IgbDropdownModule));
    

    Target

    The Blazor Dropdown list is positioned relatively to its target. The target slot allows you to provide a built-in component which toggles the open property on click. In some cases you would want to use an external target or use another event to toggle the opening of the Dropdown. You can achieve this using the Show, Hide and Toggle methods which allow you to provide the target as a parameter. By default, the Dropdown list uses absolute CSS position. You will need to set the IgbPositionStrategy of the Blazor Dropdown to fixed when the target element is inside a fixed container, but the Dropdown is not. The Dropdown list is automatically sized based on its content, if you want the list to have the same width as the target, you should set the SameWidth property to true.

    Position

    The preferred placement of the Blazor Dropdown can be set using the Placement property. The default placement of the Dropdown is bottom-start. The Flip property determines whether the placement should be flipped if there is not enough space to display the Dropdown at the specified placement. The distance from the Blazor Dropdown list to its target can be specified using the Distance property.

    선택

    The IgbDropdown emits the Change event when the user selects an item. The Select method of the Dropdown allows you to select an item by its index or value.

    Item

    The IgbDropdownItem represents a selectable item in the Dropdown list. You could predefine a selected item by setting the Selected property. You could also disable an item so that it can't be selected using the Disabled property. The IgbDropdownItem has a default slot which allows you to specify the content of the item. You could also provide custom content to be rendered before or after the content using the prefix and suffix slots. The Value property allows you to provide a custom value to an item. If the Value is not set, it resolves to the text content of the item.

    You could use the IgbDropdownHeader to provide a header for a group of items.

    Group

    The Blazor Dropdown's items can also be grouped using the IgbDropdownGroup, making it easier for users to differentiate separate categories. See it in action in this Blazor Dropdown List example:

    Scroll Strategy

    The ScrollStrategy property determines the behavior of the component during scrolling the container of the target element. The default value is scroll which means that the Dropdown will be scrolled with its target. Setting the property to block will block the scrolling if the Dropdown is opened. You could also set the property to close which means that the Dropdown will be closed automatically on scroll.

    Keep Open

    By default, the Dropdown is closed automatically when the user clicks outside of it or selects an item. You could prevent this behavior using the KeepOpenOnOutsideClick and KeepOpenOnSelect properties.

    Styling

    You can change the appearance of the Dropdown and its items, by using the exposed CSS parts. The IgbDropdown exposes base and list parts, the IgbDropdownItem exposes prefix, content and suffix parts and the IgbDropdownGroup exposes label part.

    igc-dropdown::part(list) {
      height: 220px;
    }
    
    igc-dropdown-item[selected] {
      background: var(--ig-success-300);
    }
    
    igc-dropdown-group::part(label) {
      display: flex;
      justify-content: center;
    }
    

    API Reference

    Additional Resources