A scrolling list with a search field tucked above it that appears when the user scrolls up.
Search Reveal is an open-source interaction from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
import * as React from "react"import { SearchReveal, SearchRevealContent, SearchRevealField,} from "@/components/interactions/search-reveal"const allNotes = [ { id: 1, title: "Groceries", preview: "Milk, eggs, bread, coffee" }, { id: 2, title: "Trip ideas", preview: "Lisbon, Porto, the coast road" }, { id: 3, title: "Book list", preview: "Three novels for the summer" }, { id: 4, title: "Meeting notes", preview: "Ship the beta on Friday" }, { id: 5, title: "Gift ideas", preview: "Headphones, a plant, a scarf" }, { id: 6, title: "Recipes", preview: "Lemon pasta and a quick curry" }, { id: 7, title: "Workout plan", preview: "Run on Monday, swim on Thursday" }, {
SearchReveal recreates the iOS pattern where a search field hides above a list. The container starts scrolled so the field is just out of view; scrolling up reveals it and fades it in. When scrolling stops partway, the container settles to fully shown or fully hidden, and it stays revealed while the field holds a query. Focusing the field scrolls it into view.
SearchRevealField is a controlled search input with a magnifying glass and a clear button. Use the pattern for lists such as notes, messages, or contacts where search should be available without taking up space.
A short list still hides the field above it and reveals it on focus, because SearchRevealContent fills at least the container's height.
import * as React from "react"import { SearchReveal, SearchRevealContent, SearchRevealField,} from "@/components/interactions/search-reveal"const allNotes = [ { id: 1, title: "Groceries", preview: "Milk, eggs, bread, coffee" }, { id: 2, title: "Trip ideas", preview: "Lisbon, Porto, the coast road" }, { id: 3, title: "Book list", preview: "Three novels for the summer" }, { id: 4, title: "Meeting notes", preview: "Ship the beta on Friday" }, { id: 5, title: "Gift ideas", preview: "Headphones, a plant, a scarf" }, { id: 6, title: "Recipes", preview: "Lemon pasta and a quick curry" }, { id: 7, title: "Workout plan", preview: "Run on Monday, swim on Thursday" }, {
Accessibility
The input has type="search" and is labelled by its placeholder through aria-label.
The clear button is labelled Clear search and returns focus to the input.
Focusing the field, including with the keyboard, scrolls it into view.
API Reference
SearchReveal
The scroll container that hides, reveals, and snaps the search field.
Also accepts the props of React.ComponentProps<"div">.
Place SearchRevealField first and SearchRevealContent after it inside SearchReveal, and give the container a bounded height. Each part sets a data-slot, such as search-reveal-field, for styling. The --search-reveal custom property runs from 0 to 1 as the field is revealed and drives its opacity.
SearchRevealField
The search input with a clear button.
Prop
Type
Default
value
string
Required
onValueChange
(value: string) => void
Required
Also accepts the props of React.ComponentProps<"input">.
The field is controlled: pass value and update it in onValueChange, which is called when the user types or clears the field. Filter the content from that value. placeholder defaults to Search and also labels the input.
SearchRevealContent
The scrolling content below the field.
Also accepts the props of React.ComponentProps<"div">.
Web
Web preview
import * as React from "react"import { Pressable, View } from "react-native"import { SearchReveal, SearchRevealContent, SearchRevealField,} from "@/components/interactions/search-reveal"import { Text } from "@/components/ui/text"const allNotes = [ { id: 1, title: "Groceries", preview: "Milk, eggs, bread, coffee" }, { id: 2, title: "Trip ideas", preview: "Lisbon, Porto, the coast road" }, { id: 3, title: "Book list", preview: "Three novels for the summer" }, { id: 4, title: "Meeting notes", preview: "Ship the beta on Friday" }, { id: 5, title: "Gift ideas", preview: "Headphones, a plant, a scarf" }, { id: 6, title: "Recipes", preview: "Lemon pasta and a quick curry" },
This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.
import SwiftUIstruct SearchRevealExample: View { var body: some View { SearchRevealNotes(count: 12) }}struct SearchRevealNote: Identifiable { let id: Int let title: String let preview: String}@MainActor let searchRevealNotes = [ SearchRevealNote(id: 1, title: "Groceries", preview: "Milk, eggs, bread, coffee"),
SearchReveal is a scroll view that starts scrolled just past its SearchRevealField, so the list shows first and the field is out of view. Pulling down reveals the field, which fades in as it appears, and the scroll snaps either fully open or fully hidden.
Focusing the field scrolls it into view. While there is a query, snapping is turned off so the field stays visible. Use it for notes, mail or settings lists where search should be close but not take space.
Copy and paste the following code into components/interactions/search-reveal.tsx:
uniwind/components/interactions/search-reveal.tsx
import { cn } from "cn"import { MagnifyingGlassIcon, XCircleIcon } from "phosphor-react-native"import * as React from "react"import { type LayoutChangeEvent, Pressable, type ScrollView, type ScrollViewProps, TextInput, View, type ViewProps,} from "react-native"import Animated, { type SharedValue, useAnimatedRef, useAnimatedScrollHandler,
Update the import paths to match your project setup.
import { cn } from "cn"import { cssInterop } from "nativewind"import { MagnifyingGlassIcon, XCircleIcon } from "phosphor-react-native"import * as React from "react"import { type LayoutChangeEvent, Pressable, type ScrollView, type ScrollViewProps, TextInput, View, type ViewProps,} from "react-native"import Animated, { type SharedValue, useAnimatedRef,
Update the import paths to match your project setup.
import { MagnifyingGlassIcon, XCircleIcon } from "phosphor-react-native"import * as React from "react"import { type LayoutChangeEvent, Pressable, type ScrollView, type ScrollViewProps, StyleSheet, TextInput, View, type ViewProps,} from "react-native"import Animated, { type SharedValue, useAnimatedRef, useAnimatedScrollHandler,
Update the import paths to match your project setup.
import CoreTextimport SwiftUIimport UIKitstruct RGBA: Sendable { let red: CGFloat let green: CGFloat let blue: CGFloat let alpha: CGFloat init(_ hex: UInt32, _ alpha: CGFloat = 1) { red = CGFloat((hex >> 16) & 0xFF) / 255 green = CGFloat((hex >> 8) & 0xFF) / 255 blue = CGFloat(hex & 0xFF) / 255 self.alpha = alpha }
swift/Theme/Tokens.swift
import SwiftUIpublic enum EsuissColor { public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000)) public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7)) public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F)) public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7)) public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F)) public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7)) public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF)) public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF)) public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1)) public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7)) public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617)) public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B)) public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
package com.esuiss.ui.themeimport androidx.compose.runtime.Immutableimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.unit.dp@Immutabledata class Colors( val background: Color, val foreground: Color, val card: Color, val cardForeground: Color, val popover: Color, val popoverForeground: Color, val primary: Color,
The input has the searchbox role and is labelled by placeholder.
The clear button is labelled Clear search and returns focus to the input.
API Reference
SearchReveal
The scroll view that hides and reveals the field.
Also accepts the props of ScrollViewProps.
Put a SearchRevealField first, then the list inside a SearchRevealContent, all inside SearchReveal. onScroll is the one ScrollView prop that does not pass through. Taps on the list work while the keyboard is open.
SearchRevealField
The search input with a clear button.
Prop
Type
Default
value
string
Required
onValueChange
(value: string) => void
Required
Also accepts the props of React.ComponentProps<typeof TextInput>.
Pass value and update it in onValueChange. Autocorrect and autocapitalization are off, and the return key reads search.