# @askrjs/askr/foundations/state

> Published API exports for @askrjs/askr/foundations/state.

Source: [https://askrjs.com/docs/reference/api/askr/foundations--state](https://askrjs.com/docs/reference/api/askr/foundations--state)

Status: stable. Packages: @askrjs/askr/foundations/state.

**Published packages are authoritative.** Examples may lag behind a published contract. When guidance differs, verify the exports and TypeScript declarations in your installed package, then file an issue.

## Exports

This entrypoint publishes 5 exports from the declarations shipped by @askrjs/askr.

### `controllableState`

```ts
controllableState: <T>(options: { value: T | undefined; defaultValue: T; onChange?: (next: T) => void; }) => ControllableState<T>
```

controllableState

Hook-like primitive that mirrors `state()` semantics while supporting
controlled/uncontrolled behavior.

### `ControllableState`

```ts
ControllableState: State<T> & {
  isControlled: boolean;
}
```

A {@link State} accessor that also reports whether it is controlled.

### `isControlled`

```ts
isControlled: <T>(value: T | undefined) => value is T
```

Whether `value` represents controlled mode (not `undefined`).

### `makeControllable`

```ts
makeControllable: <T>(options: { value: T | undefined; defaultValue: T; onChange?: (next: T) => void; setInternal?: (next: T) => void; }) => { set: (next: T) => void; isControlled: boolean; }
```

Build a `set` function that calls `onChange` in controlled mode, or
updates internal state and then calls `onChange` in uncontrolled mode.

### `resolveControllable`

```ts
resolveControllable: <T>(value: T | undefined, defaultValue: T) => { value: T; isControlled: boolean; }
```

Resolve the effective value and controlled-ness for a controllable prop.

## Documentation navigation

[Previous](https://askrjs.com/docs/reference/api/askr/foundations--interactions/index.md) | [Next](https://askrjs.com/docs/reference/api/askr/foundations--structures/index.md)
