Go Main page
Go Main page

Web components

cover

utilities types

useId

v.1.0.0 | Saturn
Healthy
Github

Hook to generate unique IDs that can be passed to accessibility attributes.

1
const id = useId();

Params

prefix optional parameter to prefix the ID.

Response

useId returns a unique ID string.

Usage example

12345678910
import { useId } from '@kubit-ui-web/react-components';

const MyComponent = () => {
  const id = useId();

  return (
    <div>
      <p id={id}>This is an example</p>
    </div>
  );