Web Components 확인란 개요

    Web Components 확인란은 Web Components 앱에 확인란을 추가할 수 있는 구성 요소입니다. 이는 표준 HTML 확인란처럼 작동하여 사용자가 기본 선택 및 선택 취소 상태 또는 추가 불확정 상태를 선택할 수 있도록 합니다. 또한 Web Components 확인란 구성 요소의 스타일과 이를 양식과 함께 사용하는 기능을 완벽하게 제어할 수 있습니다.

    Checkbox Example

    Usage

    기본적으로 IgcCheckboxComponent는 선택/선택 취소 상태 중에서 선택할 수 있습니다. 기본 스타일은 머티리얼 디자인 지침의 선택 제어 사양에 따라 수행됩니다.

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

    npm install igniteui-webcomponents
    

    그런 다음 필요한 CSS인 IgcCheckboxComponent를 가져오고 다음과 같이 해당 모듈을 등록해야 합니다.

    import { defineComponents, IgcCheckboxComponent } from "igniteui-webcomponents";
    import 'igniteui-webcomponents/themes/light/bootstrap.css';
    
    defineComponents(IgcCheckboxComponent);
    

    Ignite UI for Web Components 에 대한 전체 소개는 시작 항목을 참조하세요.

    IgcCheckboxComponent 사용을 시작하는 가장 간단한 방법은 다음과 같습니다.

    <igc-checkbox></igc-checkbox>
    

    [!WARNING] The IgcCheckboxComponent component doesn't work with the standard <form> element. Use IgcFormComponent instead.

    Examples

    Label

    확인란에 의미 있는 레이블을 제공하려면 여는 태그와 닫는 태그 사이에 텍스트를 배치하면 됩니다.

    <igc-checkbox>Label</igc-checkbox>
    

    확인란의 label-position 속성을 설정하여 레이블을 확인란 토글 앞 또는 뒤에 배치해야 하는지 지정할 수 있습니다. 허용되는 값은 beforeafter 입니다(기본값):

    <igc-checkbox label-position="before">Label</igc-checkbox>
    

    확인란은 확인란 외부의 요소로 레이블을 지정할 수도 있습니다. 이 경우 사용자는 필요에 따라 라벨의 위치와 스타일을 지정할 수 있는 모든 권한을 갖게 됩니다.

    <span id="checkbox-label">Label</span>
    <igc-checkbox aria-labelledby="checkbox-label"></igc-checkbox>
    

    Checked

    구성 요소의 checked 속성을 사용하여 확인란을 기본적으로 켜거나 끌지 여부를 결정할 수 있습니다.

    <igc-checkbox checked></igc-checkbox>
    

    Indeterminate

    구성 요소의 indeterminate 속성을 사용하여 확인란의 값을 true 또는 false로 설정할 수 없습니다.

    <igc-checkbox indeterminate></igc-checkbox>
    

    Required

    required 속성을 사용하여 확인란을 필수로 표시할 수 있습니다.

    <igc-checkbox required></igc-checkbox>
    

    Invalid

    invalid 속성을 사용하여 확인란을 잘못된 것으로 표시할 수 있습니다.

    <igc-checkbox invalid></igc-checkbox>
    

    Disabled

    disabled 속성을 사용하여 확인란을 비활성화할 수 있습니다.

    <igc-checkbox disabled></igc-checkbox>
    

    Forms

    당신은 사용할 수 있습니다 name 그리고 value 체크박스를 사용할 때 속성 IgcFormComponent.

    <igc-checkbox name="wifi" value="enabled"></igc-checkbox>
    

    Styling

    체크박스 구성 요소는 여러 CSS 부분(base, control, indicatorlabel)을 노출하여 스타일을 완벽하게 제어할 수 있습니다.

    igc-checkbox::part(indicator) {
      &::after {
        padding: 12px;
        border-radius: 14px;
      }
    }
    
    igc-checkbox::part(indicator checked) {
      border-radius: 0;
    
      &::after {
        background: olive;
        border-color: olive;
        stroke: beige;
      }
    }
    

    API References

    Additional Resources