본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

FloatLabel

원문 보기 위키 갱신

FloatLabel은 라벨을 폼 요소와 시각적으로 통합해 주는 컴포넌트예요. 입력 필드를 포커스하면 라벨이 필드 위로 떠오르는, 폼에서 익숙한 패턴을 손쉽게 만들 수 있게 해줘요.

출처: 문서

본문

사용법 (Usage)

import { FloatLabel } from '@primereact/ui/floatlabel';
<FloatLabel></FloatLabel>

예시 (Examples)

기본 (Basic)

포커스하면 입력 필드 위로 전환되어 올라가는 라벨이에요.

변형 (Variants)

variant 속성이 라벨의 위치를 정의해요. 기본값은 over이고, 대안으로 in과 on이 있어요.

무효 (Invalid)

폼 요소가 무효 상태면 라벨도 함께 강조 표시돼요.

접근성 (Accessibility)

화면 낭독기 (Screen Reader)

FloatLabel은 별도의 역할(role)이나 속성이 필요 없어요.

키보드 지원 (Keyboard Support)

컴포넌트는 어떤 상호작용 요소도 포함하지 않아요.

FloatLabel API

FloatLabel 컴포넌트의 API 문서예요.

FloatLabel

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?: FloatLabelInstance) => undefined | CSSProperties) null The style to apply to the component.
className string | ((instance?: FloatLabelInstance) => 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 FloatLabelInstance 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: FloatLabelInstance) => 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. | | variant | "on" | "in" | "over" | over | Defines the positioning of the label relative to the input. | | [key: string] | any | null | | | pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |

State

Exposes

Interfaces

Label Description Data
PassThroughOptions Defines passthrough(pt) options of FloatLabel component. [object Object]

Types

Label Description Data
Instance Instance of FloatLabel component. [object Object]

useFloatLabel

Props

State

Exposes

Interfaces

Types

테마 (Theming)

CSS 클래스 (CSS Classes)

styled 모드에서 사용하는 클래스 이름 목록이에요.

ClassName Description
p-floatlabel Class name of the root element

디자인 토큰 (Design Tokens)

디자인 토큰 목록이에요.

Token CSS Variable Description
floatlabel.color --p-floatlabel-color Color of root
floatlabel.focus.color --p-floatlabel-focus-color Focus color of root
floatlabel.active.color --p-floatlabel-active-color Active color of root
floatlabel.invalid.color --p-floatlabel-invalid-color Invalid color of root
floatlabel.transition.duration --p-floatlabel-transition-duration Transition duration of root
floatlabel.position.x --p-floatlabel-position-x Position x of root
floatlabel.position.y --p-floatlabel-position-y Position y of root
floatlabel.font.size --p-floatlabel-font-size Font size of root
floatlabel.font.weight --p-floatlabel-font-weight Font weight of root
floatlabel.active.font.size --p-floatlabel-active-font-size Active font size of root
floatlabel.active.font.weight --p-floatlabel-active-font-weight Active font weight of root
floatlabel.over.active.top --p-floatlabel-over-active-top Active top of over
floatlabel.in.input.padding.top --p-floatlabel-in-input-padding-top Input padding top of in
floatlabel.in.input.padding.bottom --p-floatlabel-in-input-padding-bottom Input padding bottom of in
floatlabel.in.active.top --p-floatlabel-in-active-top Active top of in
floatlabel.on.border.radius --p-floatlabel-on-border-radius Border radius of on
floatlabel.on.active.background --p-floatlabel-on-active-background Active background of on
floatlabel.on.active.padding --p-floatlabel-on-active-padding Active padding of on

더 알아보기 (Learn more)

  • FloatLabel의 세부 API를 문서에서 살펴보세요.
  • variant의 over, in, on 차이를 실제 입력에서 비교해 보세요.