useTextSelection
A hook to get the text selection and its bounding rect from an element
Loading...
Installation
npx shadcn@latest add @shadcnhooks/use-text-selectionAPI
interface Rect {
top: number
left: number
bottom: number
right: number
height: number
width: number
}
export interface State extends Rect {
text: string
}
/**
* A hook to get the text selection from an element
* @param target - The target to get the text selection from
*/
export function useTextSelection(
target?: BasicTarget<Document | Element>,
): StateCredits
Last updated on