haptics
Use haptics to confirm selection, communicate success or failure, or reinforce a physical-feeling interaction.
Distinguish selection, impact and notification feedback
import { HStack, Pressable, Text, haptics, signal } from 'kuito';
async function save(count: number): Promise<void> {
if (count > 9) throw new Error('At most 9 seats');
}
export function Seats() {
const count = signal(1);
return (
<HStack gap={12}>
<Pressable
onPress={() => {
count.value += 1;
void haptics.selection();
}}
>
<Text>{'Seats: ' + count.value}</Text>
</Pressable>
<Pressable
onPress={() => {
save(count.value).then(
() => haptics.notification('success'),
() => haptics.notification('error'),
);
}}
>
<Text>{haptics.supported ? 'Book' : 'Book (no haptics)'}</Text>
</Pressable>
</HStack>
);
}Behavior and limits
Use selection() for a changed choice, impact(style) for a collision-like response, and notification(type) for an outcome. supported reports device support. Simulators and devices without the relevant hardware may produce no feedback. Haptics should supplement a visible or spoken cue.
Continue
Read Pressable for the related workflow. The API reference lists every method, option, event and return type.
Reference
Exports 6
Methods, constants and types exposed by this native namespace.
type
ImpactStyleThe weight of the collision haptics.impact plays: 'light', 'medium' or 'heavy'.typeNotificationTypeThe outcome a notification haptic reports: 'success', 'warning' or 'error'.valuesupportedWhether the device can play haptics.functionselectionThe tick of a picker or a segmented control changing value.functionimpactA collision of a UI element of the given weight.functionnotificationThe outcome of a task.Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.