Skip to content

Hooks

The hooks behind the components, for building controls and behaviors of your own.

The components share a few hooks: for copying to the clipboard, reacting to scrolling, keyboard shortcuts, loading suggestions, and joining a Field. Each is a registry item of its own, so you can add one to build something the components don't cover, the same way you add a component:

The shadcn CLI copies it into your project's @/hooks, where it's yours to change. A component that uses a hook adds it along with itself, so you may have some already.

All hooks

  • useAsyncSuggestions

    Loads suggestions for what's typed after a pause, and tells why one is highlighted.

  • useCopyToClipboard

    Copies text to the clipboard and tracks whether it worked.

  • useField

    Connects a control Base UI doesn't build to the Field around it: its labels, description, error and state.

  • useShortcut

    Runs a callback on a keyboard shortcut and shows the shortcut the way the reader's platform writes it.