PrimeUI PRO for React is now available 🚀View Demos

IftaLabel

An unstyled wrapper that creates an infield top-aligned label for its form element.

Build an infield top-aligned label positioned inside the input boundary with complete control over layout and styling.

Features#

  • Wraps a form element and its Label to create an infield top-aligned label
  • Label stays visible inside the input boundary, above the value
  • Works with any compatible input component

Usage#

import { IftaLabel } from 'primereact/iftalabel';
import { InputText } from 'primereact/inputtext';
import { Label } from 'primereact/label';
<IftaLabel>
    <InputText id="username" />
    <Label htmlFor="username">Username</Label>
</IftaLabel>

API#

IftaLabel#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: IftaLabelInstance) => undefined | CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: IftaLabelInstance) => undefined | string)—
The class name to apply to the component.
asnull | string | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceIftaLabelInstance—
The instance to pass to the component.
ptSafeRecord<IftaLabelPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: IftaLabelInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
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—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"iftalabel"
data-part"root"

Accessibility#

Screen Reader#

IftaLabel does not require any roles and attributes.

Keyboard Support#

Component does not include any interactive elements.