Scroll Snap Align

    Utilities for controlling the scroll snap alignment of an element.

    Use the utility to snap an element to its center when being scrolled inside a snap container.

    Scroll in the grid of images to see the expected behaviour

    Scroll Snap Align - 图2

    Scroll in the grid of images to see the expected behaviour

    Scroll Snap Align - 图4

    Use the utility to snap an element to its end when being scrolled inside a snap container.

    Scroll Snap Align - 图6


    Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:snap-start to only apply the utility on hover.

    For a complete list of all available state modifiers, check out the documentation.

    You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:snap-start to apply the utility at only medium screen sizes and above.

    To learn more, check out the documentation on , Dark Mode and .