Retour au catalogue

Content Tabs Horizontal

Tabs horizontaux style Notion avec indicateur anime, contenu texte + visuel qui change a chaque onglet.

content-tabsmedium Both Responsive a11y
minimalcorporateuniversalsaasagencystacked
Theme
"use client";

import { useState } from "react";
import { motion, AnimatePresence } from "framer-motion";
import * as LucideIcons from "lucide-react";
import React from "react";

interface TabItem {
  id: string;
  label: string;
  icon?: string;
  title: string;
  description: string;
  features?: string[];
}

interface ContentTabsHorizontalProps {
  badge?: string;
  title?: string;
  subtitle?: string;
  tabs: TabItem[];
}

const EASE = [0.16, 1, 0.3, 1] as const;

function getIcon(name?: string) {
  if (!name) return null;
  return (LucideIcons as unknown as Record<string, React.ElementType>)[name] || null;
}

export default function ContentTabsHorizontal({
  badge = "Fonctionnalites",
  title = "Tout ce dont vous avez besoin",
  subtitle = "Explorez nos solutions par categorie.",
  tabs = [],
}: ContentTabsHorizontalProps) {
  const [activeTab, setActiveTab] = useState(tabs[0]?.id ?? "");

  const current = tabs.find((t) => t.id === activeTab);

  return (
    <section
      style={{
        padding: "var(--section-padding-y, 6rem) 0",
        background: "var(--color-background)",
      }}
    >
      <div
        style={{
          maxWidth: "var(--container-max-width, 1200px)",
          margin: "0 auto",
          padding: "0 var(--container-padding-x, 1.5rem)",
        }}
      >
        {/* Header */}
        <motion.div
          initial={{ opacity: 0, y: 20 }}
          whileInView={{ opacity: 1, y: 0 }}
          viewport={{ once: true, margin: "-80px" }}
          transition={{ duration: 0.5, ease: EASE }}
          style={{ textAlign: "center", maxWidth: "600px", margin: "0 auto 3rem" }}
        >
          {badge && (
            <span
              style={{
                display: "inline-block",
                fontSize: "0.75rem",
                fontWeight: 600,
                textTransform: "uppercase",
                letterSpacing: "0.08em",
                color: "var(--color-accent)",
                marginBottom: "0.75rem",
              }}
            >
              {badge}
            </span>
          )}
          <h2
            style={{
              fontFamily: "var(--font-sans)",
              fontSize: "clamp(1.75rem, 3vw, 2.75rem)",
              fontWeight: 700,
              lineHeight: 1.15,
              letterSpacing: "-0.02em",
              color: "var(--color-foreground)",
              marginBottom: "1rem",
            }}
          >
            {title}
          </h2>
          <p style={{ fontSize: "1rem", lineHeight: 1.7, color: "var(--color-foreground-muted)" }}>
            {subtitle}
          </p>
        </motion.div>

        {/* Tab bar - Notion style */}
        <div
          style={{
            display: "flex",
            gap: "0.25rem",
            borderBottom: "1px solid var(--color-border)",
            marginBottom: "2.5rem",
            overflowX: "auto",
          }}
        >
          {tabs.map((tab) => {
            const Icon = getIcon(tab.icon);
            const isActive = tab.id === activeTab;
            return (
              <button
                key={tab.id}
                onClick={() => setActiveTab(tab.id)}
                style={{
                  position: "relative",
                  display: "flex",
                  alignItems: "center",
                  gap: "6px",
                  padding: "0.75rem 1.25rem",
                  fontSize: "0.875rem",
                  fontWeight: isActive ? 600 : 400,
                  color: isActive ? "var(--color-foreground)" : "var(--color-foreground-muted)",
                  background: "none",
                  border: "none",
                  cursor: "pointer",
                  whiteSpace: "nowrap",
                  transition: "color var(--duration-fast) var(--ease-out)",
                }}
              >
                {Icon && <Icon style={{ width: 16, height: 16 }} />}
                {tab.label}
                {isActive && (
                  <motion.div
                    layoutId="tab-indicator-horizontal"
                    style={{
                      position: "absolute",
                      bottom: "-1px",
                      left: 0,
                      right: 0,
                      height: "2px",
                      background: "var(--color-accent)",
                      borderRadius: "1px 1px 0 0",
                    }}
                    transition={{ type: "spring", stiffness: 400, damping: 30 }}
                  />
                )}
              </button>
            );
          })}
        </div>

        {/* Tab content */}
        <AnimatePresence mode="wait">
          {current && (
            <motion.div
              key={current.id}
              initial={{ opacity: 0, y: 12 }}
              animate={{ opacity: 1, y: 0 }}
              exit={{ opacity: 0, y: -8 }}
              transition={{ duration: 0.3, ease: EASE }}
              style={{
                display: "grid",
                gap: "2rem",
                alignItems: "center",
              }}
              className="md:grid-cols-2"
            >
              {/* Text content */}
              <div>
                <h3
                  style={{
                    fontFamily: "var(--font-sans)",
                    fontSize: "1.5rem",
                    fontWeight: 700,
                    color: "var(--color-foreground)",
                    marginBottom: "1rem",
                  }}
                >
                  {current.title}
                </h3>
                <p
                  style={{
                    fontSize: "1rem",
                    lineHeight: 1.7,
                    color: "var(--color-foreground-muted)",
                    marginBottom: current.features?.length ? "1.5rem" : "0",
                  }}
                >
                  {current.description}
                </p>
                {current.features && current.features.length > 0 && (
                  <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: "0.5rem" }}>
                    {current.features.map((f, i) => (
                      <li
                        key={i}
                        style={{
                          display: "flex",
                          alignItems: "center",
                          gap: "0.5rem",
                          fontSize: "0.9375rem",
                          color: "var(--color-foreground-muted)",
                        }}
                      >
                        <span style={{ width: 6, height: 6, borderRadius: "var(--radius-full)", background: "var(--color-accent)", flexShrink: 0 }} />
                        {f}
                      </li>
                    ))}
                  </ul>
                )}
              </div>

              {/* Visual placeholder */}
              <div
                style={{
                  aspectRatio: "4/3",
                  borderRadius: "var(--radius-xl, 1.5rem)",
                  background: "var(--color-background-alt)",
                  border: "1px solid var(--color-border)",
                }}
              />
            </motion.div>
          )}
        </AnimatePresence>
      </div>
    </section>
  );
}

Avis

Content Tabs Horizontal — React Content-tabs Section — Incubator