React hooks
Some of the features from Primer React can be accessed via hooks in cases where a Primer component won't work as well.
useColorSchemeVar
Specifies a string value based on the active color scheme.
useConfirm
Shows a dialog for the users to confirm an action.
useDetails
Returns props for the Details component.
useFocusTrap
Traps focus within a specified element.
useFocusZone
Designates a container where focus can be moved using keys other than 'Tab'.
useFormControlForwardedProps
Provides the accessibility features of the FormControl component.
useOnEscapePress
A utility hook that calls a user-provided function when the 'Escape' key is pressed.
useOnOutsideClick
A utility hook that calls a user-provided callback function when the user clicks outside of the provided container.
useOpenAndCloseFocus
A utility hook that focuses an element when a component is first mounted and returns focus to another element when the component unmounts.
useOverlay
Provides all relevant Overlay behavior and provides a ref for the overlay's container.
useProvidedRefOrCreate
A hook that creates a ref if one is not provided as a prop.
useRefObjectAsForwardedRef
Uses a ref object as the imperative handle for a forwarded ref.
useResizeObserver
Observes and reacts to the dimensions of an element.
useResponsiveValue
Gets the value of an object with values mapped to viewport size.
useSafeTimeout
Ensures that all timeouts are cleared when a component unmounts.
useTheme
Gets data from the current theme context.