Skip to content

Ribbon

Data Display

Logical-corner card labels for featured plans and early-access content.

Featured end ribbonMuted start ribbonRTL corner placement
Open preview

Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.

Usage

Wrap card content with a short ribbon label to highlight a featured plan, release, or promotion. Logical start and end positions follow document direction. The wrapper reserves a top band so the ribbon does not overlap the content. Keep important pricing and eligibility information in the body rather than relying on the ribbon alone.

Import
import { Ribbon } from "@/components/ui/ribbon";

Shipped as editable source in src/components/ui/ribbon.tsx in both apps. Copy the implementation below when moving it to another project. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.

Component source

The complete implementation is included in both apps. It uses the React, Radix, Lucide, and shared-core dependencies already installed in Apex. Keep your project’s semantic theme tokens when reusing it.

src/components/ui/ribbon.tsx
import type { ReactNode } from "react";
import { cn } from "@dashboardpack/core/lib/utils";
export interface RibbonProps {
  label: string;
  children: ReactNode;
  position?: "start" | "end";
  tone?: "primary" | "muted";
  className?: string;
}
export function Ribbon({
  label,
  children,
  position = "end",
  tone = "primary",
  className,
}: RibbonProps) {
  return (
    <div
      className={cn(
        "relative min-w-0 rounded-xl border bg-card pt-12 shadow-xs",
        className,
      )}
    >
      <span
        className={cn(
          "absolute top-4 max-w-[calc(100%-2rem)] truncate px-3 py-1 text-xs font-semibold",
          position === "end" ? "end-0 rounded-s-md" : "start-0 rounded-e-md",
          tone === "primary"
            ? "bg-primary text-primary-foreground"
            : "bg-muted text-muted-foreground",
        )}
        title={label}
      >
        {label}
      </span>
      {children}
    </div>
  );
}

API reference

Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.

Ribbon props
PropType / DefaultDescription
labelstring

Default: required

Short readable ribbon text.
childrenReactNode

Default: required

Card body, including its own padding and heading structure.
positionstart | end

Default: end

Logical edge for placement in LTR and RTL.
toneprimary | muted

Default: primary

Ribbon background and foreground colors.
classNamestring

Default: —

Extend the component container with theme-aware utility classes.

Build with these too