React 아이콘 버튼 개요

    Ignite UI for React Icon Button 구성 요소를 사용하면 개발자가 등록된 아이콘을 애플리케이션에서 버튼으로 사용할 수 있습니다. 그것은 의 모든 기능을 가지고 있습니다. 아이콘 구성 요소이지만 단추 구성 요소뿐만 아니라.

    React Icon Button Example

    EXAMPLE
    TSX
    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인 IgrIconButton 가져오고 해당 모듈을 등록해야 합니다.

    import { IgrIconButtonModule, IgrIconButton } from 'igniteui-react';
    import 'igniteui-webcomponents/themes/light/bootstrap.css';
    IgrIconButtonModule.register();
    tsx
    <IgrIconButton name="thumb-up" collection="material"></IgrIconButton>
    tsx
    Ignite UI for React | CTA Banner

    Examples

    Variant

    일반 버튼 구성 요소와 유사하게 아이콘 버튼은 flat (기본값), containedoutlined 등 여러 변형을 지원합니다. 아이콘 버튼 유형을 변경하려면 아이콘 버튼의 variant 속성을 설정하세요.

    EXAMPLE
    TSX
    CSS

    <IgrIconButton name="search" collection="contained"></IgrIconButton>
    tsx

    크기

    버튼의 크기는--ig-size CSS 변수를 사용하여 지원되는 세 가지 크기(--ig-size-small,--ig-size-medium,--ig-size-large 중 하나로 변경할 수 있습니다( 기본).

    EXAMPLE
    TSX
    CSS

    <IgrIconButton name="thumb-up" size="medium"></IgrIconButton>
    tsx
    igc-icon-button {
        --ig-size: var(--ig-size-medium);
    }
    css

    Type

    아이콘 버튼 구성 요소는 href 속성이 설정되면 내부 구조를 <button>에서 <a> 유형 요소로 변경합니다. 이 경우 아이콘 버튼은 일반 링크로 간주될 수 있습니다. href 속성을 설정하면 아이콘 버튼의 rel, targetdownload 속성도 설정할 수 있습니다.

    <IgrIconButton name="thumb-up" collection="material" href="https://duckduckgo.com" target="_blank">
    </IgrIconButton>
    tsx

    Mirrored

    일부 아이콘은 오른쪽에서 왼쪽(RTL) 모드에서 사용될 때 약간 다르게 표시되어야 합니다. 이러한 이유로 우리는 설정 시 아이콘 버튼을 수평으로 뒤집는 mirrored 속성을 제공합니다.

    <IgrIconButton name="thumb-up" mirrored="true"></IgrIconButton>
    tsx

    Styling

    구성 요소는 IgrIconButton 래핑 요소(<button> or <a>)와 래핑된 <igc-icon> 요소의 스타일을 지정할 수 있는 두 개의 CSS 부분을 base​ ​icon 노출합니다.

    igc-icon-button[variant="contained"]:not([disabled])::part(base) {
      padding: 12px;
      background-color: var(--ig-success-500);
    }
    
    igc-icon-button::part(icon) {
      --size: 22px;
      color: var(--ig-success-500-contrast);
    }
    css

    EXAMPLE
    TSX
    IconButtonStyling.css
    index.css

    API References

    Additional Resources