UNPKG

@commercetools-uikit/field-label

Version:

The FieldLabel component represents the label for a field in a form.

54 lines (53 loc) 2.12 kB
import { MouseEvent, KeyboardEvent, ReactElement, ReactNode } from 'react'; import { type TIconProps } from '@commercetools-uikit/design-system'; export type TFieldLabelProps = { /** * Title of the label */ title: string | ReactNode; /** * Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth. Can also receive a hintIcon. */ hint?: string | ReactNode; /** * Provides a description for the title. */ description?: string | ReactNode; /** * Function called when info button is pressed. Info button will only be visible when this prop is passed. */ onInfoButtonClick?: (event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void; /** * Indicates the tone to be applied to the label */ tone?: 'primary' | 'inverted'; /** * Icon to be displayed beside the hint text. Will only get rendered when hint is passed as well. */ hintIcon?: ReactElement<TIconProps>; /** * Badge to be displayed beside the label. Might be used to display additional information about the content of the field (E.g verified email) */ badge?: ReactNode; /** * Indicates if the labeled field is required in a form */ hasRequiredIndicator?: boolean; /** * The for HTML attribute, used to reference form elements with the related attribute id or aria-labelledby. */ htmlFor?: string; /** * The id HTML attribute, used to reference non-form elements with the related attribute aria-labelledby. */ id?: string; /** * Horizontal size limit of the label. */ horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto'; }; declare const FieldLabel: { ({ horizontalConstraint, ...props }: TFieldLabelProps): import("@emotion/react/jsx-runtime").JSX.Element; displayName: string; }; export default FieldLabel;