Last modified: 16/Oct/2025
useFocusTrap
Hook for maintaining the focused element in a particular context.
#Usage
import { useFocusTrap } from '@kinsta/stratus'
const MyComponent = () => {
  const { setup, contextRef, autoFocusRef } = useFocusTrap()
  return (
    <div ref={ref}>
      This is a collapsible area
    </div>
  )
}
#Parameters
#mode
"horizontal" ǀ "vertical" ǀ "both"
#parentRef
React.RefObject<HTMLDivElement>
#Types
- 
UseFocusTrapReturn 
Read more about types here