Skip to content

@vowel.to/client v0.1.2-393


@vowel.to/client / index / useFloatingCursorOptional

Function: useFloatingCursorOptional()

ts
function useFloatingCursorOptional(): 
  | FloatingCursorContextType
  | null;

Defined in: lib/vowel/components/FloatingCursorProvider.tsx:187

Optional hook that returns null if not in FloatingCursorProvider

Use this for components that work with or without cursor support.

Returns

| FloatingCursorContextType | null

Example

tsx
function MyComponent() {
  const cursor = useFloatingCursorOptional();
  
  const handleAction = () => {
    // Only update cursor if available
    cursor?.updateCursor({ x: 50, y: 50, text: 'Action', isIdle: false });
  };
}