The closing state drives the transition
.drawer[data-state='open'] {
transform: translateX(0);
transition: transform var(--dur-exit) var(--ease-drawer);
}
.drawer[data-state='closing'] {
transform: translateX(100%); /* same curve as the entrance, in reverse */
transition: transform var(--dur-exit) var(--ease-drawer);
}
Unmounting waits for the transition to end
const [state, setState] = createSignal<'open' | 'closing' | 'closed'>('open');
// closing doesn't unmount: it goes through the intermediate state
const close = () => setState('closing');
// the content stays in place for the 200ms of the exit;
// only once the transition has finished is the panel really unmounted
const onTransitionEnd = () => {
if (state() === 'closing') setState('closed');
};