React
Switch
특정 설정 및 상태를 즉시 켜거나 끌 수 있도록 하는 컴포넌트입니다.
사용 가능 버전@seed-design/react@0.0.1, @seed-design/css@0.0.1
Installation
의존성 설치
아래 코드를 복사 후 붙여넣고 사용하세요
Props
Switch
Prop
Type
inputProps?React.InputHTMLAttributes<HTMLInputElement> | undefinedrootRef?React.Ref<HTMLLabelElement> | undefinedlabel?React.ReactNodechecked?boolean | undefineddefaultChecked?boolean | undefinedonCheckedChange?((checked: boolean) => void) | undefineddisabled?boolean | undefinedinvalid?boolean | undefinedrequired?boolean | undefinedSwitchmark
Prop
Type
Examples
Sizes
Deprecated Props
size="medium"과 size="small"은 더 이상 사용되지 않습니다. 대신 size="32"와 size="16"을 사용하세요.
Tones
Brand
Neutral
Long Label
Disabled
Listening to Value Changes
onCheckedChange를 사용하여 스위치의 선택 상태 변경을 감지할 수 있습니다.
이벤트를 활용해야 하는 경우 inputProps를 통해 내부 <input> 요소에 직접 이벤트 핸들러를 추가할 수 있습니다.
Use Cases
Using Switchmark
Switchmark는 레이블을 제외한 스위치 컴포넌트로, 커스텀 레이아웃을 위해 사용할 수 있습니다.
Scale Feedback
Switch는 눌렸을 때 Switchmark가 살짝 줄어드는 피드백을 제공합니다.
Switchmark를 감싸는 요소에 Scale Feedback을 직접 적용하는 경우, 바깥 요소와 Switchmark가 함께 줄어들어 축소가 이중으로 나타납니다. Switchmark의 상위 요소에서 --seed-switchmark-feedback-scale을 1로 설정하면 Switchmark의 축소만 끌 수 있습니다. 이 변수는 상속되므로 Switch 전체를 감싸는 요소에 설정해도 됩니다.
Last updated on