Skip to documentation

Design system / Shadcn

CreativeXHub design system

Shadcn

Local ownership of shadcn-derived components, their runtime dependencies and the process for reviewing upstream changes.

Maintain the local component contract

CreativeXHub maintains shadcn-derived source in src/components/ui/. These components use Tailwind v4, semantic theme tokens and, where needed, Radix primitives from radix-ui or Embla for Carousel. The checked-in API is the supported contract, not the latest upstream default. Custom generic components must meet the same accessibility and integration standards.

docs/decisions/ADR-0010-shadcn-and-tailwind-baseline-policy.md

Local source ownership and runtime dependencies

shadcn distributes source that the project maintains locally. A newer registry version does not automatically update checked-in components. Compare proposed changes with local APIs and adaptations. Components still use runtime dependencies, including Radix for keyboard, focus and disclosure behavior, and Embla for Carousel.

Responsibilities in shadcn adoption
PartIts responsibility
Upstream sourceA reviewed starting point, primitive-specific APIs and interaction behavior.
CreativeXHub foundationsThe semantic colors, type, geometry and Tailwind mappings used by components.
Local generic componentThe checked-in structure, props, variants and control behavior we support.
Consumer or product instanceField arrangement, help, product copy, values and behavior bindings.

Current project configuration

Selected current components.json settings
SettingCurrent value
Style / base colornew-york / neutral
React Server Components / TypeScriptrsc: true / tsx: true
CSS variablestrue
Global CSS entrysrc/app/globals.css
UI / utilities aliases@/components/ui / @/lib/utils

These selected settings come from components.json. Radix use is observed in the checked-in controls, not inferred from a missing configuration field. The current cn() helper combines clsx and tailwind-merge to compose and reconcile utility classes.

Repository path: components.json

Repository path: src/lib/utils.ts

src/components/ui/checkbox.tsx

Local adaptation can live in the theme

How existing utilities use local foundations
UtilityWhat makes it CreativeXHub-specific
bg-primary / text-primary-foregroundResolve semantic roles. A tenant palette can remap those roles without creating a new Button.
text-md / text-labelUse the fluid scale and the purpose-driven label role respectively.
p-4 / rounded-mdUse the 4px spacing multiplier and an explicit radius mapping. The 10px rem basis does not turn p-4 into 40px.
src/theming/utilities/generated.css

Review proposed component additions

Check the local inventory and current shadcn registry first. Adopt an available component and its composition patterns rather than build a parallel interaction engine. Select source compatible with the project's primitive APIs, controlled-state contracts, slots, refs, keyboard behavior and client boundaries. An upstream component called Field is a candidate, not proof that Field is installed locally.

# Examples only: choose a reviewed CLI version and a missing component.
npx shadcn@<reviewed-version> view <component>
npx shadcn@<reviewed-version> add <component> --dry-run

# Only after reviewing the proposed files and dependencies:
npx shadcn@<reviewed-version> add <component>

Record adoption evidence and local changes

Record the upstream baseline, deliberate local adaptations and affected consumers. If provenance is unknown, state that uncertainty. Component appearance does not establish its source version or change history.

Component: <name>
Upstream source: <URL / registry item>
Primitive implementation: <selected implementation>
Baseline version or commit: <known value, or unknown>
Retrieved: <date>
Local source: <path>
Supported contract: <props / variants / state API>
Local adaptation and rationale: <evidence>
Affected consumers and migration: <scope>

A template for future adoption notes—not established provenance for existing files. Local inspection tells us the present contract, not the original upstream version or who made each change.

When reconciling an update, retain accessible names, focus behavior, label associations, state contracts and slot semantics. Review dependency changes and migrate affected consumers deliberately instead of regenerating blindly.

Upstream reference material

These external, live references complement our local contracts. They are not pinned snapshots or instructions to replace the project with today's defaults.

Carousel foundation

Carousel uses the standard shadcn composition and Embla engine. Compose CarouselContent and CarouselItem inside Carousel, then add CarouselPrevious and CarouselNext. Default slides take the full width; controls sit outside the slide edges and render only when their direction has a destination. A single slide or a fully fitting set has no paddles. ContentCarousel adds CarouselMedia and overlay controls: hover or focus within media reveals available edge paddles. Mobile and touch-only devices keep Embla swipe and dot navigation without paddles. Card mode retains its heading in CardHeader, not its controls. One active-item footer can place dots beside product actions. Both variants reuse existing engine state and empty-state behavior.

Carousel foundation contracts and deliberate local adaptations
ContractSupported behavior
opts / plugins / orientation / setApiForward Embla configuration and plugins, select horizontal or vertical layout, and expose the engine API through shadcn's standard props.
CarouselContent / CarouselItemStandard overflow-hidden viewport, flex track, full-width slides and spacing. Native element props and className remain supported. Optional viewportClassName sizes the outer viewport, for example min-h-0/flex-1 for the expanded presentation; className still belongs to the inner track.
CarouselPrevious / CarouselNextShared Button props with outline/icon defaults. Each paddle returns no markup when its direction is unavailable. Embla's existing canScrollPrev/canScrollNext state also hides both when all slides fit.
CarouselMedia / CarouselOverlayControlsRelative hover/focus overlays. A supplied slideIndex excludes inactive slide controls from tab/screen-reader navigation. Omit slideIndex to mount one stable pair on the positioned carousel owner, as expanded mode does outside its changing media/footer. CSS hides paddles below md and without fine-pointer hover; no hover/touch/resize listeners are added.
CarouselIndicators / useCarouselThe bounded Context exposes selectedIndex, snapCount and scrollTo. Dots use those engine values, aria-pressed and shared Button targets; fewer than two snaps renders no group. Swipe and reInit keep selection synchronized.
Local adaptationsUse the existing cn helper and Button without overwriting them. Colocate Embla lifecycle in useCarouselBehavior under ADR-0032, remove both event subscriptions on cleanup, and leave nested media/input arrow keys untouched. Navigation buttons use type=button. Paddle availability reads existing initialization/select/reInit state; CSS handles hover/focus visibility. No polling, animation-frame work, DOM size reads or resize/scroll observers are added. Paddles never change viewport width.
State and limitsEmbla owns dragging, snapping, focus-driven selection and resizing. Context coordinates this carousel only. No custom native-scroll engine, wheel handler, autoplay, automatic video pause or engine motion override is added. Overlay fades respect reduced-motion preferences.
Live preview

Current component with fictional data. Example changes are not persisted.

Example content (4)

Example item 1
Example item 2
Example item 3
Example item 4

Contained carousel (3)

Edge-to-edge item 1
Edge-to-edge item 2
Edge-to-edge item 3
Live preview

Standard shadcn responsive slide sizing: both slides fit from sm upward; narrow screens show one slide at a time. Embla updates paddle visibility when the layout changes.

Slide 1

Slide 2

src/components/ui/carousel.tsx

Supplier is not a size tier

Shadcn can supply atoms, focused compound assemblies and larger starting points. A Dialog container completes one disclosure concern; the manager inside it may coordinate many concerns. Do not call every export an atom or classify by folder alone.

Live preview

Current component with fictional data. Example changes are not persisted.

Current local UI inventory · 42 files

Derived from the current UI directory. Availability does not prove product adoption or complete taxonomy compliance. Tests are excluded.

Before adding or updating a component

  1. Check the local library and current shadcn registry first. Use the supplied component and composition patterns instead of writing a parallel interaction engine. Review existing consumer contracts before adopting upstream changes; theme shared components separately.
  2. Declare taxonomy, owner, instance boundary, server boundary and state level.
  3. Keep domain vocabulary, API paths, tenant assumptions and business rules out of components/ui.
  4. Use semantic utilities, cn(), explicit labels, correct element semantics and supported controlled-state contracts.
  5. Test keyboard behavior, feedback, focus return and affected consumers under ADR-0033.
.opencode/skills/frontend-component-architecture/SKILL.md
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.