Cover

A flexible cover component for displaying featured images with optional action buttons for changing or removing the cover.

Preview

Cover image

Installation

Use the CLI to add this component to your project.

npx shadcn@latest add https://ui.nyxhora.com/r/cover.json

Usage

tsx
15 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { Cover } from "@/components/ui/cover"

export default function MyComponent() {
  const [coverUrl, setCoverUrl] = useState<string | undefined>(
    "https://images.unsplash.com/..."
  );

  return (
    <Cover
      url={coverUrl}
      onChange={() => console.log("Change cover")}
      onRemove={() => setCoverUrl(undefined)}
    />
  )
}

Sizes

Default (35vh)

Cover image

Small (12vh)

Cover image

Large (50vh)

Cover image

No Image (Placeholder)

No cover image

With Children

Cover image

Hero Title

Subtitle or description text

Props

PropTypeDefaultDescription
urlstringundefinedThe URL of the cover image
size'default' | 'sm' | 'lg' | 'full'defaultThe height of the cover
previewbooleanfalseIf true, hides action buttons (view-only mode)
onChange() => voidundefinedCallback when 'Change cover' button is clicked
onRemove() => voidundefinedCallback when 'Remove' button is clicked
childrenReactNodeundefinedContent to render inside the cover (e.g., overlays)
classNamestringundefinedAdditional CSS classes