# Scroll Auto Hide URL: /breeze/components/scroll-auto-hide Source: https://github.com/daangn/seed-design/blob/dev/docs/content/breeze/components/scroll-auto-hide.mdx Component that hides and reveals fixed areas based on scroll direction `ScrollAutoHide` hides a fixed area when scrolling down. When scrolling up, it reveals it again by the same distance. It's suitable for areas where you want more content space, like filters, tabs, and secondary headers. ## Preview ```tsx "use client"; import { IconChevronDownFill } from "@karrotmarket/react-monochrome-icon"; import { Badge, Box, Flex, HStack, Icon, Text, VStack } from "@seed-design/react"; import { useRef } from "react"; import { ScrollAutoHide } from "seed-design/breeze/scroll-auto-hide/scroll-auto-hide"; import { Avatar } from "seed-design/ui/avatar"; import { Chip } from "seed-design/ui/chip"; import { IdentityPlaceholder } from "seed-design/ui/identity-placeholder"; import { TabsList, TabsRoot, TabsTrigger } from "seed-design/ui/tabs"; import { TagGroupItem, TagGroupRoot } from "seed-design/ui/tag-group"; type Article = { author: string; title: string; content: string; category: string; date: string; popular?: boolean; }; const ARTICLES = [ { author: "magna", title: "독서 습관 만들기", content: "하루 10페이지부터 시작하자. 취침 전 20분 독서는 수면의 질도 높여줘요.", category: "라이프스타일", date: "12월 4일", popular: true, }, { author: "ullamco", title: "알프스 하이킹 가이드", content: "그린델발트에서 시작해 아이거 북벽을 감상하는 초보자용 코스를 소개해요.", category: "여행", date: "10월 15일", }, { author: "consectetur", title: "커피 브루잉 팁", content: "물 온도 92도, 중간 분쇄도와 3분의 추출 시간이 기본이에요.", category: "음식", date: "9월 25일", }, { author: "exercitation", title: "실내 공기 정화 식물", content: "관리하기 쉽고 공기 정화 능력이 뛰어난 식물을 모아봤어요.", category: "라이프스타일", date: "8월 7일", }, { author: "elit", title: "아침 루틴의 힘", content: "따뜻한 물 한 잔과 가벼운 스트레칭으로 하루를 시작해보세요.", category: "라이프스타일", date: "7월 28일", popular: true, }, ] satisfies Article[]; const FILTERS = ["카테고리", "동네", "작성자", "작성 시간"]; export default function ScrollAutoHidePreview() { const scrollContainerRef = useRef(null); return ( Demo 추천 구독 {FILTERS.map((filter) => ( {filter} } /> ))} {ARTICLES.map((article) => ( } size="20" /> {article.author} {article.title} {article.content} {article.popular && ( 인기 )} ))} ); } ``` ## Installation Dependency: - npm: npm install @radix-ui/react-compose-refs @radix-ui/react-slot - pnpm: pnpm add @radix-ui/react-compose-refs @radix-ui/react-slot - yarn: yarn add @radix-ui/react-compose-refs @radix-ui/react-slot - bun: bun add @radix-ui/react-compose-refs @radix-ui/react-slot Snippet: - npm: npx @seed-design/cli@latest add breeze:scroll-auto-hide - pnpm: pnpm dlx @seed-design/cli@latest add breeze:scroll-auto-hide - yarn: yarn dlx @seed-design/cli@latest add breeze:scroll-auto-hide - bun: bun x @seed-design/cli@latest add breeze:scroll-auto-hide ## Usage Pass the ref of the element where scrolling occurs to `scrollContainerRef`. Since the component applies `position: sticky` and `top: 0`, it must be placed inside the scroll container. ```tsx const scrollContainerRef = useRef(null); return (
{/* Content to scroll */}
); ``` ### Using a Different Element as Root Use `asChild` to use the child element as the root without an unnecessary wrapper. The child must be a single React element. ```tsx
Filters
``` ## Behavior and Style - While scrolling, it follows the movement distance exactly. Once scrolling ends, it fully hides or reveals based on the 50% point. - Snapping uses `cubic-bezier(0, 0, 0.15, 1)`, Crispy's `enter` timing function, for 200ms. - In reduced motion settings, auto-hiding is disabled to avoid position changes. - If keyboard focus moves into the hidden area, content is immediately revealed. - The component uses `translate3d()` to compose well in wide webview versions. In browsers supporting `ScrollTimeline`, the browser directly connects scrolling and movement; in other environments, the same behavior is handled via scroll events. - The root element's `transform` is used for internal movement. If additional `transform` is needed, apply it to child elements. - Background color and `z-index` are specified directly for your use case. Without a background color, content underneath may show through while hiding. ## Props