IconField
IconField는 입력 요소와 아이콘을 감싸 주는 컴포넌트예요. 입력 필드 안쪽에 아이콘을 배치하고 싶을 때, 위치 잡기를 직접 하지 않아도 되게 해줘요.
출처: 문서
본문
사용법 (Usage)
import { IconField } from '@primereact/ui/iconfield';
<IconField.Root>
<IconField.Inset />
</IconField.Root>
예시 (Examples)
기본 (Basic)
앞이나 뒤에 아이콘이 내장된 입력 필드예요.
플로팅 라벨 (Float Label)
FloatLabel은 라벨을 폼 요소와 시각적으로 통합해 줘요. 더 자세한 내용은 FloatLabel 문서를 확인하세요.
Ifta 라벨 (Ifta Label)
IftaLabel은 필드 안쪽 상단 정렬 라벨을 만들 때 사용해요. 더 자세한 내용은 IftaLabel 문서를 확인하세요.
클릭 가능 (Clickable)
IconField.Inset 안의 아이콘은 onClick 같은 이벤트 핸들러로 인터랙티브하게 만들 수 있어요.
크기 (Sizes)
IconField는 입력 필드의 크기 설정과 호환돼요.
접근성 (Accessibility)
화면 낭독기 (Screen Reader)
IconField.Root와 IconField.Inset은 별도의 역할(role)이나 속성이 필요 없어요.
키보드 지원 (Keyboard Support)
컴포넌트는 어떤 상호작용 요소도 포함하지 않아요.
IconField API
IconField 컴포넌트의 API 문서예요.
IconFieldRoot
Props
| Name | Type | Default | Description |
|---|---|---|---|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties | ((instance?: IconFieldRootInstance) => undefined | CSSProperties) | null | The style to apply to the component. |
| className | string | ((instance?: IconFieldRootInstance) => undefined | string) | null | The class name to apply to the component. |
| as | null | string | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent | ReactElement<unknown, string | JSXElementConstructor> | Iterable<ReactNode, any, any> | ReactPortal | Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| instance | IconFieldRootInstance | null | The instance to pass to the component. |
| pt | SafeRecord | null | The pass-through props to pass to the component. |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component. |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| render | (instance: IconFieldRootInstance) => ReactNode | null | The render function to render the component with instance access. |
| children | any | null | The children to render. |
Accepts React.ReactNode for static content or a render function (instance: I) => React.ReactNode for instance access.
Typed as any to avoid JSX type errors when used directly in templates. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
State
Exposes
| Name | Type | Default | Description |
|---|---|---|---|
| rootProps | UseIconFieldRootProps | null | Pre-built data attribute props for the root element. |
Interfaces
| Label | Description | Data |
|---|---|---|
| PassThroughOptions | Defines passthrough(pt) options of IconFieldRoot component. | [object Object],[object Object] |
Types
| Label | Description | Data |
|---|---|---|
| Instance | Instance of IconFieldRoot component. | [object Object] |
IconFieldInset
Props
| Name | Type | Default | Description |
|---|---|---|---|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties | ((instance?: IconFieldInsetInstance) => undefined | CSSProperties) | null | The style to apply to the component. |
| className | string | ((instance?: IconFieldInsetInstance) => undefined | string) | null | The class name to apply to the component. |
| as | null | string | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent | ReactElement<unknown, string | JSXElementConstructor> | Iterable<ReactNode, any, any> | ReactPortal | Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| instance | IconFieldInsetInstance | null | The instance to pass to the component. |
| pt | SafeRecord | null | The pass-through props to pass to the component. |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component. |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| render | (instance: IconFieldInsetInstance) => ReactNode | null | The render function to render the component with instance access. |
| children | any | null | The children to render. |
Accepts React.ReactNode for static content or a render function (instance: I) => React.ReactNode for instance access.
Typed as any to avoid JSX type errors when used directly in templates. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
Exposes
| Name | Type | Default | Description |
|---|---|---|---|
| iconfield | undefined | null | IconFieldRootInstance | null | The IconField component instance. |
Interfaces
| Label | Description | Data |
|---|---|---|
| PassThroughOptions | Defines passthrough(pt) options of IconFieldInset component. | [object Object] |
Types
| Label | Description | Data |
|---|---|---|
| Instance | Instance of IconFieldInset component. | [object Object] |
useIconField
Props
State
Exposes
Interfaces
Types
테마 (Theming)
CSS 클래스 (CSS Classes)
styled 모드에서 사용하는 클래스 이름 목록이에요.
| ClassName | Description |
|---|---|
| p-iconfield | Class name of the root element |
| p-inputicon | Class name of the icon element |
디자인 토큰 (Design Tokens)
디자인 토큰 목록이에요.
| Token | CSS Variable | Description |
|---|---|---|
| iconfield.icon.color | --p-iconfield-icon-color | Color of icon |
더 알아보기 (Learn more)
- IconField 서브 컴포넌트의 세부 API를 문서에서 살펴보세요.
- FloatLabel이나 IftaLabel과 함께 사용해 입력 경험을 다듬어 보세요.