scrollToId

Hace scroll suave a un elemento por su ID.

#browser #scroll #dom #utility
export const scrollToId = (id: string) => {
const el = document.getElementById(id);
if (!el) return;
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
};
// Usage
scrollToId('section-2');

Comparte este snippet

Comentarios