폼과 선택@neumorphism-ui/radio-group

Radio Group

React context로 name과 선택 상태를 공유하면서 각 항목은 실제 input[type=radio]로 렌더링합니다. controlled와 uncontrolled 값, 가로·세로 배치, disabled와 required를 지원합니다.

@neumorphism-ui/radio-group
Registry JSON

미리보기

설치

설치: radio-groupnpx shadcn@latest add @neumorphism-ui/radio-group

CLI가 npm 의존성, base 토큰, utils와 컴포넌트 소스를 순서대로 확인하고 설치합니다.

Registry를 처음 사용한다면 namespace 설정 을 먼저 완료하세요.

사용법

사용법: 설치npx shadcn@latest add @neumorphism-ui/radio-group @neumorphism-ui/label

Import

Radio Group import 코드
import {
  RadioGroup,
  RadioGroupItem,
} from "@/components/ui/radio-group"
import { Label } from "@/components/ui/label"

Example

Radio Group 사용 코드
<RadioGroup
  defaultValue="comfortable"
  orientation="horizontal"
  aria-label="화면 밀도"
>
  <Label className="flex gap-2" htmlFor="density-compact">
    <RadioGroupItem id="density-compact" value="compact" />
    Compact
  </Label>
  <Label className="flex gap-2" htmlFor="density-comfortable">
    <RadioGroupItem id="density-comfortable" value="comfortable" />
    Comfortable
  </Label>
</RadioGroup>

API 레퍼런스

컴포넌트속성타입기본값설명
RadioGroupvalue / defaultValuestring—controlled 또는 초기 uncontrolled 선택 값입니다.
RadioGrouponValueChange(value: string) => void—선택 값이 바뀔 때 호출됩니다.
RadioGrouporientation"horizontal" | "vertical""vertical"배치 방향과 aria-orientation을 설정합니다.
RadioGroupnamestringgenerated id항목이 공유하는 native radio name입니다.
RadioGroupdisabled / requiredbooleanfalse모든 항목의 입력 제약을 설정합니다.
RadioGroupItemvalue필수string—항목이 선택됐을 때 그룹에 전달할 값입니다.

접근성

  • 01

    RadioGroup root에는 aria-label 또는 aria-labelledby로 그룹 전체의 이름을 제공합니다.

  • 02

    각 RadioGroupItem은 id와 Label htmlFor를 연결합니다.

  • 03

    실제 radio input을 사용하므로 브라우저의 폼 제출과 키보드 선택 동작을 유지합니다.