HistoryControls
Undo and redo a bounded edit history, including the branch created by a new change.
Live — this one is real
Usage
import { HistoryControls, useHistory, InlineEdit, Stack } from "mizu-ui";
export function Example() {
const history = useHistory("First draft");
return (
<Stack gap={16}>
<InlineEdit
label="Draft name"
value={history.value}
onValueChange={history.set}
/>
<HistoryControls
canUndo={history.canUndo}
canRedo={history.canRedo}
onUndo={history.undo}
onRedo={history.redo}
/>
</Stack>
);
}
Source & setup
Import mizu-ui/styles.css once. Fonts are optional via mizu-ui/fonts.css. Override --mizu-* tokens or use className for local styling. Uses native React and CSS; install the package peers for root imports.
Inspect interaction/HistoryControls.tsx
Source is included in the npm package under src/interaction/HistoryControls.tsx.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| useHistory(initial, limit?) | hook | — | Value, set, undo, redo, reset and availability; bounded to 50 past entries by default. |
| canUndo / canRedo | boolean | — | Availability from your history. |
| onUndo / onRedo | function | — | Actual history operations. |
Accessibility
Named button group with explicit disabled boundaries. Store immutable values; Object.is suppresses unchanged edits. A new edit clears the redo branch.
Motion
State changes belong to the edited content.