selectOnFocus

selectOnFocus selects the input / textarea contents whenever the element gains focus — pairs well with autoFocus for "click to edit" UI. Part of pota/use/focus.

Examples

Select-all on focus

Composes with autoFocus: the field focuses on mount and its contents are selected, ready to overtype.

import { render } from 'pota'
import { autoFocus, selectOnFocus } from 'pota/use/focus'

function App() {
	return (
		<input
			value="select me on focus"
			use:ref={[autoFocus, selectOnFocus]}
		/>
	)
}

render(App)