# wrRandomId

> Short prefixed random id, for `<label for>` and `aria-describedby` pairs.

Source: https://ngwr.dev/reference/utils/wr-random-id  
Kind: Util  
Updated in v16  
Optional

## Usage

```angular-ts
import { wrRandomId } from 'ngwr/utils';

const id = wrRandomId('wr-input');       // 'wr-input-a8f2bx1k9q4z'
const short = wrRandomId('wr-input', 6); // 'wr-input-h7m4k2'
```

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `wrRandomId(prefix?, length?, random?)` | Random id such as `wr-input-a8f2bx1k9q4z`, safe on the server. `length` is the random part, clamped to `[4, 64]`. `random` replaces the byte source, for a fixed id in tests. | `(prefix = 'wr', length = 12, random?: (byteLength: number) => Uint8Array) => string` | `—` |

## See also

- [Form Field](https://ngwr.dev/reference/components/form-field) — Wraps a form control with a label, a hint and its error messages.
- [Form](https://ngwr.dev/reference/components/form) — A plain layout wrapper for a label, a control and its error.
