React 버튼 그룹 개요

    React Button Group 구성 요소는 수평/수직 정렬, 단일/다중 선택 및 토글을 통해 스타일이 지정된 버튼 그룹으로 구성하는 IgrToggleButton 데 사용됩니다.

    React Button Example

    EXAMPLE
    TSX
    ButtonGroupOverview.css
    index.css

    Like this sample? Get access to our complete Ignite UI for React toolkit and start building your own apps in minutes. Download it for free.

    Usage

    먼저, 다음 명령을 실행하여 Ignite UI for React 설치해야 합니다.

    npm install igniteui-react
    cmd

    그런 다음 필요한 CSS를 IgrButtonGroup 가져 와서 다음과 같이 모듈을 등록해야합니다.

    import { IgrButtonGroupModule, IgrButtonGroup } from 'igniteui-react';
    import 'igniteui-webcomponents/themes/light/bootstrap.css';
    
    IgrButtonModule.register();
    tsx

    Ignite UI for React에 대한 전체 소개를 보려면 시작하기 항목을 읽어보세요.

    이제 Ignite UI for React Button Group을 가져왔으므로 의 기본 구성으로 시작할 수 있습니다. IgrButtonGroup 그리고 그 버튼.

    선택기를 IgrButtonGroup 사용하여 s를 IgrToggleButton 래핑하고 버튼 그룹에 표시합니다. 버튼이 기본적으로 선택되도록 하려면 다음 속성을 사용합니다. selected

    <IgrButtonGroup>
        <IgrToggleButton value="left" key="button-left">
            <IgrIcon name="format_align_left" collection="material" key="icon-left" />
            <IgrRipple key="ripple-left" />
        </IgrToggleButton>
        <IgrToggleButton value="center" key="button-center">
            <IgrIcon name="format_align_center" collection="material" key="icon-center" />
            <IgrRipple key="ripple-center" />
        </IgrToggleButton>
        <IgrToggleButton value="right" key="button-right">
            <IgrIcon name="format_align_right" collection="material" key="icon-right" />
            <IgrRipple key="ripple-right" />
        </IgrToggleButton>
        <IgrToggleButton value="justify" selected={true} key="button-justify">
            <IgrIcon name="format_align_justify" collection="material" key="icon-justify" />
            <IgrRipple key="ripple-justify" />
        </IgrToggleButton>
    </IgrButtonGroup>
    tsx
    Ignite UI for React | CTA Banner

    Examples

    Alignment

    alignment 속성을 사용하여 단추 그룹에 있는 단추의 방향을 설정할 수 있습니다.

    EXAMPLE
    TSX
    ButtonGroupAlignment.css
    index.css

    선택

    Ignite UI for React 구성하려면 IgrButtonGroup 선택, 당신은 그것을 사용할 수 있습니다 selection 재산. 이 속성은 다음과 같은 세 가지 모드를 허용합니다.

    • 단일- 버튼 그룹의 기본 선택 모드입니다. 사용자는 하나의 버튼을 선택/선택 취소할 수 있습니다.
    • single-required- 라디오 그룹 동작을 모방합니다. 하나의 버튼만 선택할 수 있으며 초기 선택이 이루어지면 사용자 상호 작용을 통해 선택을 취소할 수 없습니다.
    • 여러 - 그룹에서 여러 버튼을 선택하거나 선택 취소할 수 있습니다.

    아래 샘플은 노출 IgrButtonGroup 된 선택 모드를 보여줍니다.

    EXAMPLE
    TSX
    ButtonGroupSelection.css
    index.css

    A IgrToggleButton는 해당 selected 속성 또는 다음을 통해 선택된 것으로 표시될 수 있습니다. IgrButtonGroup selectedItems 속성:

    <IgrButtonGroup selectedItems={['bold']}>
        <IgrToggleButton value="bold" key="button-bold">
            <IgrIcon name="bold" collection="material" key="icon-bold" />
            <IgrRipple key="ripple-bold" />
        </IgrToggleButton>
        <IgrToggleButton value="italic" key="button-italic">
            <IgrIcon name="italic" collection="material" key="icon-italic" />
            <IgrRipple key="ripple-italic" />
        </IgrToggleButton>
        <IgrToggleButton value="underlined" key="button-underlined">
            <IgrIcon name="underlined" collection="material" key="icon-underlined" />
            <IgrRipple key="ripple-underlined" />
        </IgrToggleButton>
    </IgrButtonGroup>
    tsx

    Setting IgrToggleButton value attribute is mandatory for using the selectedItems property of the IgrButtonGroup.

    크기

    --ig-size CSS 사용자 정의 속성을 사용하여 버튼 그룹의 크기를 제어할 수 있습니다.

    EXAMPLE
    TSX
    CSS

    Styling

    IgrButtonGroup 구성 요소는 버튼 그룹 컨테이너의 스타일을 지정할 수 있는 CSS 부분을 노출 group 합니다. 또한 s는 IgrToggleButton 버튼 요소의 스타일을 지정하는 데 사용할 수 있는 CSS 부분을 제공합니다 toggle.

    igc-button-group::part(group) {
      background-color: var(--ig-primary-500);
      padding: 8px;
    }
    
    igc-toggle-button::part(toggle) {
      color: var(--ig-secondary-300);
    }
    css

    EXAMPLE
    TSX
    ButtonGroupStyling.css
    index.css

    API Reference

    Additional Resources