Design system / Molecules
Molecule / Content browsing
ContentCarousel
ContentCarousel adds a title, optional header action and empty state to shadcn's Carousel. Plain/card keep media-edge paddles. Expanded fills its owner's height without a Card and anchors one paddle pair to that complete owner's midpoint, independently of the active footer's height.
Live example
Current component with fictional data. Example changes are not persisted.
Example content (4)
Contained carousel (3)
Responsibility
Compose Carousel, CarouselContent, CarouselItem, CarouselPrevious and CarouselNext instead of implementing scrolling. Embla supplies dragging, snapping, resizing and direction availability. Product-specific media remains outside this molecule.
Public contract
The table describes supported inputs, exported parts and caller responsibilities. A callback supplies a command, such as saving a draft. These notes are maintained manually; check current source types before integration.
| Prop / part | Type | Requirement | Responsibility |
|---|---|---|---|
| title | string | Required | Collection and accessible carousel name. Visible h2 by default: plain uses text-lg; card and expanded use text-label. |
| showTitle | boolean | Optional | Defaults to true. false removes the visible h2 while retaining an accessible region name. CardHeader is omitted when neither a title nor a headerAction is present; expanded mode retains slide position and header actions. |
| items | readonly { id: string; content: ReactNode; footer?: ReactNode }[] | Required | Stable IDs and supplied preview elements. Optional footer renders once for the selected item, outside the moving track. Omitted footer uses centered dots. |
| emptyMessage | string | Optional | Defaults to No items to display. |
| variant | plain | card | expanded | Optional | Defaults to plain. card uses CardHeader and full-width slides. expanded fills its owner's available height without a Card, retains a fixed header/footer and lets media use the remaining height. The owner must supply height-constrained media. |
| headerAction | ReactNode | Optional | CardHeader action in card mode or right-aligned header action in expanded mode; plain mode does not render it. ContentShowcase supplies Expand or Close. |
| startIndex / setApi | number / (api: CarouselApi) => void | Optional | Initial Embla snap (default zero) and the existing engine API callback. Not a continuously controlled index or a second navigation engine. |
| className | string | Optional | Outer placement only. |
API notes are curated documentation, not generated types. The source linked above is the current implementation; update these notes alongside API changes.
State and behavior
Identify which values the caller controls and which behavior the component or underlying primitive owns. A local example does not supply persistence, authorization or a complete product lifecycle.
The molecule adds no engine, effect or subscription. Its footer reads selection from the existing compound Context. useCarouselBehavior derives selectedScrollSnap, scrollSnapList length and direction availability during initialization/select/reInit, and exposes scrollTo for dots. Both subscriptions are cleaned up. No additional listeners, polling, measurements or application store are added.
Dependencies
- Carousel / CarouselContent / CarouselItem
- CarouselMedia / CarouselOverlayControls / CarouselIndicators
- Card / CardHeader / CardContent
- Text
- embla-carousel-react through the shadcn foundation
Token and styling contract
These notes identify theme roles, utilities and direct style values used by the source. Direct colors or timings are implementation exceptions, not recommendations to bypass the theme.
CarouselItem basis-full- Full-width slides. Plain retains inter-item pl-4/-ml-4; card/expanded use pl-0/ml-0. No outside paddle gutters are reserved.
CarouselMedia / CarouselOverlayControls- Inline controls are vertically centered on their relative media owner. Expanded mode mounts one unindexed pair at the complete positioned carousel owner's midpoint, outside moving slides and the variable-height footer. Both use left-3/right-3, hover/focus visibility and hidden mobile/coarse-pointer paddles. Only indexed inactive-slide controls leave tab/screen-reader navigation.
CarouselIndicators / Button ghost icon-xs- One centered group of 24px dot buttons with aria-pressed; fewer than two snaps hides it. Commands use the existing Embla API.
Card / CardHeader / CardContent- Compact card heading and full-width body. The footer has its own symmetric inset and never changes media width.
Boundaries and limitations
- Each Previous/Next paddle renders only when Embla reports a destination in that direction. A single slide or fully fitting set has no paddles. Existing initialization/select/reInit state supplies availability; CSS handles hover/focus visibility. No extra size reads, polling or resize/scroll observers are added. Navigation does not change slide width.
- Focus the carousel root for left/right keys. Nested media, inputs and item actions retain their own keys. Embla owns pointer dragging, focus-driven slide selection and resizing.
- The former native-scroll, bounded-height and fitting-item design is removed. There is no custom wheel handler, engine motion override, auto-rotation or automatic video pause. Overlay fades respect reduced-motion preferences.
- The composition does not fetch files, embed viewers, virtualize slides or resolve permissions.
Where to make a change
Maintain interaction and shared styling in the shadcn Carousel foundation. Keep this molecule limited to title, supplied slides/footers, navigation composition and empty state. Change media rendering in the owning feature.
Selected real uses
ContentShowcase
The generic collection owns cards and optional carousel presentation plus dialog launch without adding modal behavior to ContentCarousel.
src/components/showcase/contentShowcase.tsxSubmissionShowcase
Supplies authorized preview and footer nodes through the generic collection.
Repository path: src/components/showcase/instances/submissionShowcase.tsx
These traces describe selected uses, not every dependency. Repository-only paths are shown as references; only approved files have public source views.
Usage contract
<ContentCarousel title="Examples" items={[{ id: "first", content: <Card><CardContent>First item</CardContent></Card> }]} />Illustrative consumer bindings, not a self-contained product workflow. Live examples supply only local state or explicit fictional props.