Skip to main content
Our new developer certification is live!

SearchResultCard

Compact card for displaying search results and typeahead suggestions.

Props

PropTypeRequiredDefaultDescription
resultSearchSuggestionYes-Search result data
compactbooleanNotrueUse smaller image size (40px vs 52px)
onClick() => voidNo-Callback when card is clicked

SearchSuggestion Interface

interface SearchSuggestion {
  title: string;
  url: string;
  _content_type: 'blogpost' | 'guide' | 'person' | 'live_stream' | string;
  image?: {
    url: string;
    alt?: string;
  };
}

Usage

import { SearchResultCard } from '@/components/cards';

<SearchResultCard
  result={{
    title: "Getting Started with Contentstack",
    url: "/blog/getting-started",
    _content_type: "blogpost",
    image: { url: "/image.jpg", alt: "Blog image" }
  }}
  onClick={() => closeDropdown()}
/>

Features

  • Image or icon fallback: Shows result image if available, otherwise a content-type icon
  • Content type badge: Displays label based on content type (Blog, Guide, Live Stream, Person)
  • Hover effects: Background color change and teal accent on title
  • Accessible: Focus-visible outline for keyboard navigation

Content Type Mapping

Content TypeLabelFallback Icon
blogpostBlogdescription
guideGuidedescription
live_streamLive Streamplay_arrow
personPersonperson

Notes

  • Used by HeaderSearch for typeahead suggestions
  • Uses MediaItem for images and Icons for fallback icons
  • Links to result URL using Next.js Link