Patternfly Logo

Examples

Basic

Please provide your full name

Horizontal

Please provide your full name

Invalid

Age has to be a number

Validated

Enter your age to continue

Horizontal no padding top

Props

ActionGroup properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeNonullAnything that can be rendered as ActionGroup content.
classNamestringNo''Additional classes added to the ActionGroup.
Form properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeNonullAnything that can be rendered as Form content.
classNamestringNo''Additional classes added to the Form.
isHorizontalbooleanNofalseSets the Form to horizontal.
FormGroup properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeNonullAnything that can be rendered as FormGroup content.
classNamestringNo''Additional classes added to the FormGroup.
fieldIdstringYesID of the included field. It has to be the same for proper working.
hasNoPaddingTopbooleanNofalseRemoves top spacer from label.
helperTextReact.ReactNodeNoHelper text after the field. It can be a simple text or an object.
helperTextIconReact.ReactNodeNoIcon displayed to the left of the helper text.
helperTextInvalidReact.ReactNodeNoHelper text after the field when the field is invalid. It can be a simple text or an object.
helperTextInvalidIconReact.ReactNodeNoIcon displayed to the left of the helper text when the field is invalid.
isInlinebooleanNofalseSets the FormGroup isInline.
isRequiredbooleanNofalseSets the FormGroup required.
labelReact.ReactNodeNoLabel text before the field.
labelIconReact.ReactElementNoSets an icon for the label. For providing additional context. Host element for Popover
validated'success' | 'warning' | 'error' | 'default'No'default'Sets the FormGroup validated. If you set to success, text color of helper text will be modified to indicate valid state. If set to error, text color of helper text will be modified to indicate error state. If set to warning, text color of helper text will be modified to indicate warning state.
FormHelperText properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeNonullContent rendered inside the Helper Text Item
classNamestringNo''Additional classes added to the Helper Text Item
iconReact.ReactNodeNonullIcon displayed to the left of the helper text.
isErrorbooleanNofalseAdds error styling to the Helper Text *
isHiddenbooleanNotrueHides the helper text *
Button properties
NameTypeRequiredDefaultDescription
aria-labelstringNonullAdds accessible text to the button.
childrenReact.ReactNodeNonullContent rendered inside the button
classNamestringNo''Additional classes added to the button
componentReact.ElementType<any>No'button'Sets the base component to render. defaults to button
iconReact.ReactNode | nullNonullIcon for the button. Usable by all variants except for plain.
iconPosition'left' | 'right'No'left'Sets position of the link icon
inoperableEventsBetastring[]No['onClick', 'onKeyPress']Events to prevent when the button is in an aria-disabled state
isActivebooleanNofalseAdds active styling to button.
isAriaDisabledBetabooleanNofalseAdds disabled styling and communicates that the button is disabled using the aria-disabled html attribute
isBlockbooleanNofalseAdds block styling to button
isDisabledbooleanNofalseAdds disabled styling and disables the button using the disabled html attribute
isInlinebooleanNofalseAdds inline styling to a link button
isLargebooleanNofalseAdds large styling to the button
isLoadingbooleanNonullAdds progress styling to button
isSmallbooleanNofalseAdds small styling to the button
ouiaSafeNo type infoNotrue
spinnerAriaValueTextstringNoAria-valuetext for the loading spinner
tabIndexnumberNonullSets the button tabindex.
type'button' | 'submit' | 'reset'NoButtonType.buttonSets button type
variant'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'link' | 'plain' | 'control'NoButtonVariant.primaryAdds button variant styles
Popover properties
NameTypeRequiredDefaultDescription
animationDurationnumberNo300CSS fade transition animation duration
appendToHTMLElement | ((ref?: HTMLElement) => HTMLElement)No() => document.bodyThe element to append the popover to, defaults to body
aria-labelstringNo''Accessible label, required when header is not present
bodyContentReact.ReactNodeYesBody content
Deprecated: boundary'scrollParent' | 'window' | 'viewport' | HTMLElementNo- no longer used. if you want to constrain the popper to a specific element use the appendTo prop instead
childrenReactElement<any>NoThe reference element to which the Popover is relatively placed to. If you cannot wrap the reference with the Popover, you can use the reference prop instead. Usage: <Popover><Button>Reference</Button></Popover>
classNamestringNo''Popover additional class
closeBtnAriaLabelstringNo'Close'Aria label for the Close button
distancenumberNo25Distance of the popover to its target, defaults to 25
enableFlipbooleanNotrueIf true, tries to keep the popover in view by flipping it if necessary If the position is set to 'auto', this prop is ignored
flipBehavior'flip' | ('top' | 'bottom' | 'left' | 'right')[]No['top', 'right', 'bottom', 'left', 'top', 'right', 'bottom']The desired position to flip the popover to if the initial position is not possible. By setting this prop to 'flip' it attempts to flip the popover to the opposite side if there is no space. You can also pass an array of positions that determines the flip order. It should contain the initial position followed by alternative positions if that position is unavailable. Example: Initial position is 'top'. Button with popover is in the top right corner. 'flipBehavior' is set to ['top', 'right', 'left']. Since there is no space to the top, it checks if right is available. There's also no space to the right, so it finally shows the popover on the left.
footerContentReact.ReactNodeNonullFooter content
headerContentReact.ReactNodeNonullHeader content, leave empty for no header
hideOnOutsideClickbooleanNotrueHides the popover when a click occurs outside (only works if isVisible is not controlled by the user)
idstringNoid used as part of the various popover elements (popover-${id}-header/body/footer)
isVisiblebooleanNonullTrue to show the popover programmatically. Used in conjunction with the shouldClose prop. By default, the popover child element handles click events automatically. If you want to control this programmatically, the popover will not auto-close if the Close button is clicked, ESC key is used, or if a click occurs outside the popover. Instead, the consumer is responsible for closing the popover themselves by adding a callback listener for the shouldClose prop.
maxWidthstringNopopoverMaxWidth && popoverMaxWidth.valueMaximum width of the popover (default 18.75rem)
minWidthstringNopopoverMinWidth && popoverMinWidth.valueMinimum width of the popover (default 6.25rem)
onHidden(tip?: TippyInstance) => voidNo(): void => nullLifecycle function invoked when the popover has fully transitioned out. Note: The tip argument is no longer passed and has been deprecated.
onHide(tip?: TippyInstance) => voidNo(): void => nullLifecycle function invoked when the popover begins to transition out. Note: The tip argument is no longer passed and has been deprecated.
onMount(tip?: TippyInstance) => voidNo(): void => nullLifecycle function invoked when the popover has been mounted to the DOM. Note: The tip argument is no longer passed and has been deprecated.
onShow(tip?: TippyInstance) => voidNo(): void => nullLifecycle function invoked when the popover begins to transition in. Note: The tip argument is no longer passed and has been deprecated.
onShown(tip?: TippyInstance) => voidNo(): void => nullLifecycle function invoked when the popover has fully transitioned in. Note: The tip argument is no longer passed and has been deprecated.
position'auto' | 'top' | 'bottom' | 'left' | 'right'No'top'Popover position. Note: With 'enableFlip' set to true, it will change the position if there is not enough space for the starting position. The behavior of where it flips to can be controlled through the flipBehavior prop.
referenceHTMLElement | (() => HTMLElement) | React.RefObject<any>NoThe reference element to which the Popover is relatively placed to. If you can wrap the reference with the Popover, you can use the children prop instead. Usage: <Popover reference={() => document.getElementById('reference-element')} />
shouldClose(tip?: TippyInstance, hideFunction?: () => void) => voidNo(): void => nullCallback function that is only invoked when isVisible is also controlled. Called when the popover Close button is clicked, Enter key was used on it, or the ESC key is used. Note: The tip argument is no longer passed and has been deprecated.
shouldOpen(showFunction?: () => void) => voidNo(): void => nullCallback function that is only invoked when isVisible is also controlled. Called when the Enter key is used on the focused trigger
Deprecated: tippyPropsPartial<TippyProps>No- no longer used
zIndexnumberNo9999z-index of the popover

CSS variables

.pf-c-form--pf-c-form--GridGap
1.5rem
.pf-c-form--pf-c-form__group--m-action--MarginTop
2rem
.pf-c-form--pf-c-form--m-horizontal__group-label--md--GridColumnWidth
9.375rem
.pf-c-form--pf-c-form--m-horizontal__group-label--md--GridColumnGap
1rem
.pf-c-form--pf-c-form--m-horizontal__group-control--md--GridColumnWidth
1fr
.pf-c-form--pf-c-form--m-limit-width--MaxWidth
31.25rem
.pf-c-form--pf-c-form--m-horizontal__group-label--md--PaddingTop
0.5rem
.pf-c-form--pf-c-form__group-label--PaddingBottom
0.5rem
.pf-c-form--pf-c-form__label--FontSize
0.875rem
.pf-c-form--pf-c-form__label--LineHeight
1.3
.pf-c-form--pf-c-form__label--m-disabled--Color
#6a6e73
.pf-c-form--pf-c-form__label-text--FontWeight
700
.pf-c-form--pf-c-form__label-required--MarginLeft
0.25rem
.pf-c-form--pf-c-form__label-required--FontSize
0.875rem
.pf-c-form--pf-c-form__label-required--Color
#c9190b
.pf-c-form--pf-c-form__group-label-help--PaddingTop
0.25rem
.pf-c-form--pf-c-form__group-label-help--PaddingRight
0.25rem
.pf-c-form--pf-c-form__group-label-help--PaddingBottom
0.25rem
.pf-c-form--pf-c-form__group-label-help--PaddingLeft
0.25rem
.pf-c-form--pf-c-form__group-label-help--MarginTop
calc(0.25rem * -1)
.pf-c-form--pf-c-form__group-label-help--MarginRight
calc(0.25rem * -1)
.pf-c-form--pf-c-form__group-label-help--MarginBottom
calc(0.25rem * -1)
.pf-c-form--pf-c-form__group-label-help--MarginLeft
calc(0.25rem * -1 + 0.25rem)
.pf-c-form--pf-c-form__group-label-help--FontSize
0.875rem
.pf-c-form--pf-c-form__group-label-help--TranslateY
0.125rem
.pf-c-form--pf-c-form__group-control--m-inline--child--MarginRight
1.5rem
.pf-c-form--pf-c-form__group-control__helper-text--MarginBottom
0.25rem
.pf-c-form--pf-c-form__actions--child--MarginTop
0.5rem
.pf-c-form--pf-c-form__actions--child--MarginRight
0.5rem
.pf-c-form--pf-c-form__actions--child--MarginBottom
0.5rem
.pf-c-form--pf-c-form__actions--child--MarginLeft
0.5rem
.pf-c-form--pf-c-form__actions--MarginTop
calc(0.5rem * -1)
.pf-c-form--pf-c-form__actions--MarginRight
calc(0.5rem * -1)
.pf-c-form--pf-c-form__actions--MarginBottom
calc(0.5rem * -1)
.pf-c-form--pf-c-form__actions--MarginLeft
calc(0.5rem * -1)
.pf-c-form--pf-c-form__helper-text--MarginTop
0.25rem
.pf-c-form--pf-c-form__helper-text--FontSize
0.875rem
.pf-c-form--pf-c-form__helper-text--Color
#151515
.pf-c-form--pf-c-form__helper-text-icon--FontSize
1rem
.pf-c-form--pf-c-form__helper-text-icon--MarginRight
0.25rem
.pf-c-form--pf-c-form__helper-text--m-success--Color
#1e4f18
.pf-c-form--pf-c-form__helper-text--m-warning--Color
#795600
.pf-c-form--pf-c-form__helper-text--m-error--Color
#c9190b
.pf-c-form--pf-c-form__section--MarginTop
2rem
.pf-c-form--pf-c-form__section--Gap
1.5rem
.pf-c-form.pf-m-horizontal--pf-c-form__group-label--PaddingBottom
0
.pf-c-form__group-label--pf-c-form__helper-text--MarginTop
0
.pf-c-form__group-control .pf-c-form__helper-text:first-child--pf-c-form__helper-text--MarginTop
0
.pf-c-form__helper-text.pf-m-error--pf-c-form__helper-text--Color
#c9190b
.pf-c-form__helper-text.pf-m-success--pf-c-form__helper-text--Color
#1e4f18
.pf-c-form__helper-text.pf-m-warning--pf-c-form__helper-text--Color
#795600

View source on GitHub