Web Components 라디오 & 라디오 그룹
Ignite UI for Web Components Radio 구성 요소를 사용하면 나란히 나열된 사용 가능한 옵션 집합에서 단일 옵션을 선택할 수 있습니다.
Ignite UI for Web Components Radio Example
Usage
먼저 다음 명령을 실행하여 Ignite UI for Web Components 설치해야 합니다.
npm install igniteui-webcomponents
와 theIgcRadioComponent를 사용하기IgcRadioGroupComponent 전에 다음과 같이 등록해야 합니다:
import { defineComponents, IgcRadioComponent, IgcRadioGroupComponent } from 'igniteui-webcomponents';
import 'igniteui-webcomponents/themes/light/bootstrap.css';
defineComponents(IgcRadioComponent, IgcRadioGroupComponent);
Ignite UI for Web Components에 대한 완전한 소개는 '시작 주제'를 읽어보세요.
사용하기 가장 간단한 방법은IgcRadioComponent 다음과 같습니다:
<igc-radio-group>
<igc-radio>Apple</igc-radio>
<igc-radio>Banana</igc-radio>
<igc-radio>Mango</igc-radio>
<igc-radio>Orange</igc-radio>
</igc-radio-group>
[!WARNING] The
IgcRadioComponentcomponent doesn't work with the standard<form>element. UseForminstead.
Examples
Label
에 의미 있는 라벨IgcRadioComponent을 부여하려면, 시작 태그와 종료 태그 사이에 텍스트를 넣으면 됩니다:
<igc-radio>Apple</igc-radio>
라벨을 다음에 배치할지 지정할 수 있습니다.IgcRadioComponent 버튼을 설정하여label-position 속성. 허용된 값은 다음과 같습니다before 그리고after (기본값):
<igc-radio label-position="before">Apple</igc-radio>
또한 외부IgcRadioComponent의 원소로도 라벨링할 수 있습니다. 이 경우 사용자는 자신의 필요에 따라 라벨을 위치하고 스타일링할 수 있는 완전한 권한을 부여받습니다.
<span id="radio-label">Label</span>
<igc-radio aria-labelledby="radio-label"></igc-radio>
Checked
이 속성을 사용checked 해 라디오를 켜는 것도 가능합니다.
<igc-radio-group>
<igc-radio>Apple</igc-radio>
<igc-radio checked>Banana</igc-radio>
<igc-radio>Mango</igc-radio>
<igc-radio>Orange</igc-radio>
</igc-radio-group>
Invalid
속성을 사용invalid 해 무전기를 유효하지 않게 표시할 수 있습니다.
<igc-radio invalid></igc-radio>
Disabled
이 속성을 사용disabled 해 무전기를 비활성화할 수 있습니다.
<igc-radio-group>
<igc-radio>Apple</igc-radio>
<igc-radio disabled>Banana</igc-radio>
<igc-radio>Mango</igc-radio>
<igc-radio>Orange</igc-radio>
</igc-radio-group>
Group Alignment
IgcRadioGroupComponent이 기능은 속성으로alignment 포함된 라디오 버튼의 배치 방향성을 쉽게 변경할 수 있게 해줍니다. 허용된 값은vertical (기본값) 와horizontal 입니다.
<igc-radio-group alignment="horizontal">
<igc-radio>Apple</igc-radio>
<igc-radio>Banana</igc-radio>
<igc-radio>Mango</igc-radio>
<igc-radio>Orange</igc-radio>
</igc-radio-group>
Forms
라디오name를 사용할 때 ANDvalue 속성을 사용할Form 수 있습니다.
<igc-radio-group>
<igc-radio name="fruit" value="apple">Apple</igc-radio>
<igc-radio name="fruit" value="banana">Banana</igc-radio>
<igc-radio name="fruit" value="mango">Mango</igc-radio>
<igc-radio name="fruit" value="banana">Orange</igc-radio>
</igc-radio-group>
Styling
컴포넌트는IgcRadioComponent 여러 CSS 부분(base,control, andlabel)을 노출하여 스타일링을 완전히 제어할 수 있게 합니다.
igc-radio::part(control) {
--size: 18px;
}
igc-radio-group {
padding: 12px;
}
igc-radio::part(checked)::after {
background-color: var(--ig-success-500);
}
igc-radio::part(label) {
color: var(--ig-secondary-800);
}