Examples
When using helper text inside a FormGroup
, the HelperText
component should be wrapped with the FormHelperText
component to provide additional spacing.
Props
ActionGroup
Name | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | null | Anything that can be rendered as ActionGroup content. |
className | string | '' | Additional classes added to the ActionGroup. |
Form
Name | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | Anything that can be rendered as Form content. | |
className | string | Additional classes added to the Form. | |
isHorizontal | boolean | Sets the Form to horizontal. | |
isWidthLimited | boolean | Limits the max-width of the form. | |
maxWidth | string | Sets a custom max-width for the form. |
FormGroup
Name | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | null | Anything that can be rendered as FormGroup content. |
className | string | '' | Additional classes added to the FormGroup. |
fieldId | string | ID of an individual field or a group of multiple fields. Required when a role of "group" or "radiogroup" is passed in. If only one field is included, its ID attribute and this prop must be the same. | |
hasNoPaddingTop | boolean | false | Removes top spacer from label. |
isInline | boolean | false | Sets the FormGroup isInline. |
isRequired | boolean | false | Sets the FormGroup required. |
isStack | boolean | false | Sets the FormGroupControl to be stacked |
label | React.ReactNode | Label text before the field. | |
labelHelp | React.ReactElement | A help button for the label. We recommend using FormGroupLabelHelp element as a help icon button. The help button should be wrapped or linked to our popover component. | |
labelInfo | React.ReactNode | Additional label information displayed after the label. | |
role | string | Sets the role of the form group. Pass in "radiogroup" when the form group contains multiple radio inputs, or pass in "group" when the form group contains multiple of any other input type. |
FormGroupLabelHelp
Name | Type | Default | Description |
---|---|---|---|
aria-labelrequired | string | Adds an accessible name for the help button. | |
className | string | Additional classes added to the help button. |
FormSection
Name | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | Content rendered inside the section | |
className | string | '' | Additional classes added to the section |
title | React.ReactNode | '' | Title for the section |
titleElement | 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'div' | Element to wrap the section title |
FormHelperText
Name | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | null | Content rendered inside the helper text wrapper |
className | string | '' | Additional classes added to the helper text wrapper |
FormFieldGroup
Name | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | Anything that can be rendered as form field group content. | |
className | string | Additional classes added to the form field group. | |
header | React.ReactNode | Form field group header |
FormFieldGroupExpandable
Name | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | Anything that can be rendered as form field group content. | |
className | string | Additional classes added to the form field group. | |
header | React.ReactNode | Form field group header | |
isExpanded | boolean | false | Flag indicating if the form field group is initially expanded |
toggleAriaLabel | string | Aria-label to use on the form field group toggle button |
FormFieldGroupHeader
Name | Type | Default | Description |
---|---|---|---|
actions | React.ReactNode | Field group header actions | |
className | string | Additional classes added to the section | |
titleDescription | React.ReactNode | Field group header title description | |
titleText | FormFieldGroupHeaderTitleTextObject | Field group header title text |
FormFieldGroupHeaderTitleTextObject
Name | Type | Default | Description |
---|---|---|---|
idrequired | string | The id applied to the title div for accessibility | |
textrequired | React.ReactNode | Title text. |
FormContextProps
Name | Type | Default | Description |
---|---|---|---|
errorsrequired | Record<string, string> | Record of errors for all fieldIds | |
getErrorrequired | string | Get the error message for a given fieldId | |
getValuerequired | string | Get the value for a given fieldId | |
isTouchedrequired | boolean | Used to determine touched state for a given fieldId | |
isValidrequired | boolean | Flag to determine the overall validity. True if the record of errors is empty. | |
setErrorrequired | void | Set the error message for a given fieldId | |
setErrorsrequired | Dispatch<SetStateAction<Record<string, string>>> | Set multiple errors within the managed record of errors | |
setTouchedrequired | void | Used to update the touched state for a given fieldId | |
setValidatorrequired | void | Set a validator for a specific fieldId | |
setValuerequired | void | Set the value for a given fieldId | |
setValuesrequired | Dispatch<SetStateAction<Record<string, string>>> | Set multiple values within the managed record of values | |
touchedrequired | Record<string, boolean> | Record of touched state for all fieldIds | |
validaterequired | Record<string, string | null> | Triggers all fieldId-specific validators | |
valuesrequired | Record<string, string> | Record of values for all fieldIds |
FormContextProviderProps
Name | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | ((props: FormContextProps) => React.ReactNode) | Any react node. Can optionally use render function to return context props. | |
initialValues | Record<string, string> | Record of initial values |
Button
Name | Type | Default | Description |
---|---|---|---|
aria-label | string | Adds accessible text to the button. | |
children | React.ReactNode | Content rendered inside the button | |
className | string | Additional classes added to the button | |
component | React.ElementType<any> | React.ComponentType<any> | Sets the base component to render. defaults to button | |
countOptions | BadgeCountObject | Adds count number to button | |
hasNoPadding | boolean | Applies no padding on a plain button variant. Use when plain button is placed inline with text | |
icon | React.ReactNode | null | Icon for the button. Usable by all variants except for plain. | |
iconPosition | 'start' | 'end' | 'left' | 'right' | Sets position of the icon. Note: "left" and "right" are deprecated. Use "start" and "end" instead | |
inoperableEvents | string[] | Events to prevent when the button is in an aria-disabled state | |
isAriaDisabled | boolean | Adds disabled styling and communicates that the button is disabled using the aria-disabled html attribute | |
isBlock | boolean | Adds block styling to button | |
isClicked | boolean | Adds clicked styling to button. | |
isDanger | boolean | Adds danger styling to secondary or link button variants | |
isDisabled | boolean | Adds disabled styling and disables the button using the disabled html attribute | |
isInline | boolean | Adds inline styling to a link button | |
isLoading | boolean | Adds progress styling to button | |
ouiaId | number | string | Value to overwrite the randomly generated data-ouia-component-id. | |
ouiaSafe | boolean | Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. | |
size | 'default' | 'sm' | 'lg' | Adds styling which affects the size of the button | |
spinnerAriaLabel | string | Accessible label for the spinner to describe what is loading | |
spinnerAriaLabelledBy | string | Id of element which describes what is being loaded | |
spinnerAriaValueText | string | Text describing that current loading status or progress | |
state | 'read' | 'unread' | 'attention' | Sets state of the stateful button variant. Default is "unread" | |
tabIndex | number | Sets the button tabindex. | |
type | 'button' | 'submit' | 'reset' | Sets button type | |
variant | 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'link' | 'plain' | 'control' | 'stateful' | Adds button variant styles |
Popover
Name | Type | Default | Description |
---|---|---|---|
bodyContentrequired | React.ReactNode | ((hide: () => void) => React.ReactNode) | Body content of the popover. If you want to close the popover after an action within the body content, you can use the isVisible prop for manual control, or you can provide a function which will receive a callback as an argument to hide the popover, i.e. bodyContent={hide => <Button onClick={() => hide()}>Close</Button>} | |
alertSeverityScreenReaderText | string | Text announced by screen reader when alert severity variant is set to indicate severity level. | |
alertSeverityVariant | 'custom' | 'info' | 'warning' | 'success' | 'danger' | Severity variants for an alert popover. This modifies the color of the header to match the severity. | |
animationDuration | number | 300 | The duration of the CSS fade transition animation. |
appendTo | HTMLElement | ((ref?: HTMLElement) => HTMLElement) | 'inline' | () => document.body | The element to append the popover to. Defaults to "inline". |
aria-label | string | '' | Accessible label for the popover, required when header is not present. |
children | ReactElement<any> | The trigger reference element to which the popover is relatively placed to. If you cannot wrap the element with the Popover, you can use the triggerRef prop instead. Usage: <Popover><Button>Reference</Button></Popover> | |
className | string | '' | Additional classes added to the popover. |
closeBtnAriaLabel | string | 'Close' | Accessible label for the close button. |
distance | number | 25 | Distance of the popover to its target. Defaults to 25. |
elementToFocus | HTMLElement | SVGElement | string | The element to focus when the popover becomes visible. By default the first focusable element will receive focus. | |
enableFlip | boolean | true | If 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' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end' )[] | [ 'top', 'bottom', 'left', 'right', 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end', 'right-start', 'right-end' ] | 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. |
footerContent | React.ReactNode | ((hide: () => void) => React.ReactNode) | null | Footer content of the popover. If you want to close the popover after an action within the footer content, you can use the isVisible prop for manual control, or you can provide a function which will receive a callback as an argument to hide the popover, i.e. footerContent={hide => <Button onClick={() => hide()}>Close</Button>} |
hasAutoWidth | boolean | false | Removes fixed-width and allows width to be defined by contents. |
hasNoPadding | boolean | false | Allows content to touch edges of popover container. |
headerComponent | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'h6' | Sets the heading level to use for the popover header. Defaults to h6. |
headerContent | React.ReactNode | ((hide: () => void) => React.ReactNode) | null | Simple header content to be placed within a title. If you want to close the popover after an action within the header content, you can use the isVisible prop for manual control, or you can provide a function which will receive a callback as an argument to hide the popover, i.e. headerContent={hide => <Button onClick={() => hide()}>Close</Button>} |
headerIcon | React.ReactNode | null | Icon to be displayed in the popover header. * |
hideOnOutsideClick | boolean | true | Hides the popover when a click occurs outside (only works if isVisible is not controlled by the user). |
id | string | Id used as part of the various popover elements (popover-${id}-header/body/footer). | |
isVisible | boolean | null | True 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, the escape 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. |
maxWidth | string | popoverMaxWidth && popoverMaxWidth.value | Maximum width of the popover (default 18.75rem). |
minWidth | string | popoverMinWidth && popoverMinWidth.value | Minimum width of the popover (default 6.25rem). |
onHidden | () => void | (): void => null | Lifecycle function invoked when the popover has fully transitioned out. |
onHide | (event: MouseEvent | KeyboardEvent) => void | (): void => null | Lifecycle function invoked when the popover begins to transition out. |
onMount | () => void | (): void => null | Lifecycle function invoked when the popover has been mounted to the DOM. |
onShow | (event: MouseEvent | KeyboardEvent) => void | (): void => null | Lifecycle function invoked when the popover begins to transition in. |
onShown | () => void | (): void => null | Lifecycle function invoked when the popover has fully transitioned in. |
position | | PopoverPosition | 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end' | 'top' | Popover position. Note: With the enableFlip property 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 property. |
shouldClose | (event: MouseEvent | KeyboardEvent, hideFunction?: () => void) => void | (): void => null | Callback function that is only invoked when isVisible is also controlled. Called when the popover close button is clicked, the enter key was used on it, or the escape key is used. |
shouldOpen | (event: MouseEvent | KeyboardEvent, showFunction?: () => void) => void | (): void => null | Callback function that is only invoked when isVisible is also controlled. Called when the enter key is used on the focused trigger. |
showClose | boolean | true | Flag indicating whether the close button should be shown. |
triggerAction | 'click' | 'hover' | 'click' | Sets an interaction to open popover, defaults to "click" |
triggerRef | HTMLElement | (() => HTMLElement) | React.RefObject<any> | The trigger reference element to which the popover is relatively placed to. If you can wrap the element with the popover, you can use the children prop instead, or both props together. When passed along with the trigger prop, the div element that wraps the trigger will be removed. Usage: <Popover triggerRef={() => document.getElementById('reference-element')} /> | |
withFocusTrap | boolean | Whether to trap focus in the popover. | |
zIndex | number | 9999 | The z-index of the popover. |
CSS variables
Expand or collapse column | Selector | Variable | Value |
---|