Menu

Tailwind CSS Stroke

The stroke property is primarily associated with SVG elements to define the outline color for visual elements such as shapes, lines, and text.

Tailwind CSS offers a range of utility classes to simplify working with the stroke property, enabling developers to apply consistent and reusable stroke styles for SVGs effortlessly. With these utilities, developers have precise control over stroke colors, states, breakpoints, and custom values for creating polished interfaces.

This help document provides comprehensive insights into utilizing Tailwind's stroke utilities effectively, tailored for developers of all levels.

ClassPropertiesExample
stroke-nonestroke: none;<div className="stroke-none"></div>
stroke-inheritstroke: inherit;<div className="stroke-inherit"></div>
stroke-currentstroke: currentColor;<div className="stroke-current"></div>
stroke-transparentstroke: transparent;<div className="stroke-transparent"></div>
stroke-blackstroke: #000;<div className="stroke-black"></div>
stroke-whitestroke: #fff;<div className="stroke-white"></div>
stroke-slate-50stroke: #f8fafc;<div className="stroke-slate-50"></div>
stroke-slate-100stroke: #f1f5f9;<div className="stroke-slate-100"></div>
stroke-slate-200stroke: #e2e8f0;<div className="stroke-slate-200"></div>
stroke-slate-300stroke: #cbd5e1;<div className="stroke-slate-300"></div>
stroke-slate-400stroke: #94a3b8;<div className="stroke-slate-400"></div>
stroke-slate-500stroke: #64748b;<div className="stroke-slate-500"></div>
stroke-slate-600stroke: #475569;<div className="stroke-slate-600"></div>
stroke-slate-700stroke: #334155;<div className="stroke-slate-700"></div>
stroke-slate-800stroke: #1e293b;<div className="stroke-slate-800"></div>
stroke-slate-900stroke: #0f172a;<div className="stroke-slate-900"></div>
stroke-slate-950stroke: #020617;<div className="stroke-slate-950"></div>
stroke-gray-50stroke: #f9fafb;<div className="stroke-gray-50"></div>
stroke-gray-100stroke: #f3f4f6;<div className="stroke-gray-100"></div>
stroke-gray-200stroke: #e5e7eb;<div className="stroke-gray-200"></div>
stroke-gray-300stroke: #d1d5db;<div className="stroke-gray-300"></div>
stroke-gray-400stroke: #9ca3af;<div className="stroke-gray-400"></div>
stroke-gray-500stroke: #6b7280;<div className="stroke-gray-500"></div>
stroke-gray-600stroke: #4b5563;<div className="stroke-gray-600"></div>
stroke-gray-700stroke: #374151;<div className="stroke-gray-700"></div>
stroke-gray-800stroke: #1f2937;<div className="stroke-gray-800"></div>
stroke-gray-900stroke: #111827;<div className="stroke-gray-900"></div>
stroke-gray-950stroke: #030712;<div className="stroke-gray-950"></div>
stroke-zinc-50stroke: #fafafa;<div className="stroke-zinc-50"></div>
stroke-zinc-100stroke: #f4f4f5;<div className="stroke-zinc-100"></div>
stroke-zinc-200stroke: #e4e4e7;<div className="stroke-zinc-200"></div>
stroke-zinc-300stroke: #d4d4d8;<div className="stroke-zinc-300"></div>
stroke-zinc-400stroke: #a1a1aa;<div className="stroke-zinc-400"></div>
stroke-zinc-500stroke: #71717a;<div className="stroke-zinc-500"></div>
stroke-zinc-600stroke: #52525b;<div className="stroke-zinc-600"></div>
stroke-zinc-700stroke: #3f3f46;<div className="stroke-zinc-700"></div>
stroke-zinc-800stroke: #27272a;<div className="stroke-zinc-800"></div>
stroke-zinc-900stroke: #18181b;<div className="stroke-zinc-900"></div>
stroke-zinc-950stroke: #09090b;<div className="stroke-zinc-950"></div>
stroke-neutral-50stroke: #fafafa;<div className="stroke-neutral-50"></div>
stroke-neutral-100stroke: #f5f5f5;<div className="stroke-neutral-100"></div>
stroke-neutral-200stroke: #e5e5e5;<div className="stroke-neutral-200"></div>
stroke-neutral-300stroke: #d4d4d4;<div className="stroke-neutral-300"></div>
stroke-neutral-400stroke: #a3a3a3;<div className="stroke-neutral-400"></div>
stroke-neutral-500stroke: #737373;<div className="stroke-neutral-500"></div>
stroke-neutral-600stroke: #525252;<div className="stroke-neutral-600"></div>
stroke-neutral-700stroke: #404040;<div className="stroke-neutral-700"></div>
stroke-neutral-800stroke: #262626;<div className="stroke-neutral-800"></div>
stroke-neutral-900stroke: #171717;<div className="stroke-neutral-900"></div>
stroke-neutral-950stroke: #0a0a0a;<div className="stroke-neutral-950"></div>
stroke-stone-50stroke: #fafaf9;<div className="stroke-stone-50"></div>
stroke-stone-100stroke: #f5f5f4;<div className="stroke-stone-100"></div>
stroke-stone-200stroke: #e7e5e4;<div className="stroke-stone-200"></div>
stroke-stone-300stroke: #d6d3d1;<div className="stroke-stone-300"></div>
stroke-stone-400stroke: #a8a29e;<div className="stroke-stone-400"></div>
stroke-stone-500stroke: #78716c;<div className="stroke-stone-500"></div>
stroke-stone-600stroke: #57534e;<div className="stroke-stone-600"></div>
stroke-stone-700stroke: #44403c;<div className="stroke-stone-700"></div>
stroke-stone-800stroke: #292524;<div className="stroke-stone-800"></div>
stroke-stone-900stroke: #1c1917;<div className="stroke-stone-900"></div>
stroke-stone-950stroke: #0c0a09;<div className="stroke-stone-950"></div>
stroke-red-50stroke: #fef2f2;<div className="stroke-red-50"></div>
stroke-red-100stroke: #fee2e2;<div className="stroke-red-100"></div>
stroke-red-200stroke: #fecaca;<div className="stroke-red-200"></div>
stroke-red-300stroke: #fca5a5;<div className="stroke-red-300"></div>
stroke-red-400stroke: #f87171;<div className="stroke-red-400"></div>
stroke-red-500stroke: #ef4444;<div className="stroke-red-500"></div>
stroke-red-600stroke: #dc2626;<div className="stroke-red-600"></div>
stroke-red-700stroke: #b91c1c;<div className="stroke-red-700"></div>
stroke-red-800stroke: #991b1b;<div className="stroke-red-800"></div>
stroke-red-900stroke: #7f1d1d;<div className="stroke-red-900"></div>
stroke-red-950stroke: #450a0a;<div className="stroke-red-950"></div>
stroke-orange-50stroke: #fff7ed;<div className="stroke-orange-50"></div>
stroke-orange-100stroke: #ffedd5;<div className="stroke-orange-100"></div>
stroke-orange-200stroke: #fed7aa;<div className="stroke-orange-200"></div>
stroke-orange-300stroke: #fdba74;<div className="stroke-orange-300"></div>
stroke-orange-400stroke: #fb923c;<div className="stroke-orange-400"></div>
stroke-orange-500stroke: #f97316;<div className="stroke-orange-500"></div>
stroke-orange-600stroke: #ea580c;<div className="stroke-orange-600"></div>
stroke-orange-700stroke: #c2410c;<div className="stroke-orange-700"></div>
stroke-orange-800stroke: #9a3412;<div className="stroke-orange-800"></div>
stroke-orange-900stroke: #7c2d12;<div className="stroke-orange-900"></div>
stroke-orange-950stroke: #431407;<div className="stroke-orange-950"></div>
stroke-amber-50stroke: #fffbeb;<div className="stroke-amber-50"></div>
stroke-amber-100stroke: #fef3c7;<div className="stroke-amber-100"></div>
stroke-amber-200stroke: #fde68a;<div className="stroke-amber-200"></div>
stroke-amber-300stroke: #fcd34d;<div className="stroke-amber-300"></div>
stroke-amber-400stroke: #fbbf24;<div className="stroke-amber-400"></div>
stroke-amber-500stroke: #f59e0b;<div className="stroke-amber-500"></div>
stroke-amber-600stroke: #d97706;<div className="stroke-amber-600"></div>
stroke-amber-700stroke: #b45309;<div className="stroke-amber-700"></div>
stroke-amber-800stroke: #92400e;<div className="stroke-amber-800"></div>
stroke-amber-900stroke: #78350f;<div className="stroke-amber-900"></div>
stroke-amber-950stroke: #451a03;<div className="stroke-amber-950"></div>
stroke-yellow-50stroke: #fefce8;<div className="stroke-yellow-50"></div>
stroke-yellow-100stroke: #fef9c3;<div className="stroke-yellow-100"></div>
stroke-yellow-200stroke: #fef08a;<div className="stroke-yellow-200"></div>
stroke-yellow-300stroke: #fde047;<div className="stroke-yellow-300"></div>
stroke-yellow-400stroke: #facc15;<div className="stroke-yellow-400"></div>
stroke-yellow-500stroke: #eab308;<div className="stroke-yellow-500"></div>
stroke-yellow-600stroke: #ca8a04;<div className="stroke-yellow-600"></div>
stroke-yellow-700stroke: #a16207;<div className="stroke-yellow-700"></div>
stroke-yellow-800stroke: #854d0e;<div className="stroke-yellow-800"></div>
stroke-yellow-900stroke: #713f12;<div className="stroke-yellow-900"></div>
stroke-yellow-950stroke: #422006;<div className="stroke-yellow-950"></div>
stroke-lime-50stroke: #f7fee7;<div className="stroke-lime-50"></div>
stroke-lime-100stroke: #ecfccb;<div className="stroke-lime-100"></div>
stroke-lime-200stroke: #d9f99d;<div className="stroke-lime-200"></div>
stroke-lime-300stroke: #bef264;<div className="stroke-lime-300"></div>
stroke-lime-400stroke: #a3e635;<div className="stroke-lime-400"></div>
stroke-lime-500stroke: #84cc16;<div className="stroke-lime-500"></div>
stroke-lime-600stroke: #65a30d;<div className="stroke-lime-600"></div>
stroke-lime-700stroke: #4d7c0f;<div className="stroke-lime-700"></div>
stroke-lime-800stroke: #3f6212;<div className="stroke-lime-800"></div>
stroke-lime-900stroke: #365314;<div className="stroke-lime-900"></div>
stroke-lime-950stroke: #1a2e05;<div className="stroke-lime-950"></div>
stroke-green-50stroke: #f0fdf4;<div className="stroke-green-50"></div>
stroke-green-100stroke: #dcfce7;<div className="stroke-green-100"></div>
stroke-green-200stroke: #bbf7d0;<div className="stroke-green-200"></div>
stroke-green-300stroke: #86efac;<div className="stroke-green-300"></div>
stroke-green-400stroke: #4ade80;<div className="stroke-green-400"></div>
stroke-green-500stroke: #22c55e;<div className="stroke-green-500"></div>
stroke-green-600stroke: #16a34a;<div className="stroke-green-600"></div>
stroke-green-700stroke: #15803d;<div className="stroke-green-700"></div>
stroke-green-800stroke: #166534;<div className="stroke-green-800"></div>
stroke-green-900stroke: #14532d;<div className="stroke-green-900"></div>
stroke-green-950stroke: #052e16;<div className="stroke-green-950"></div>
stroke-emerald-50stroke: #ecfdf5;<div className="stroke-emerald-50"></div>
stroke-emerald-100stroke: #d1fae5;<div className="stroke-emerald-100"></div>
stroke-emerald-200stroke: #a7f3d0;<div className="stroke-emerald-200"></div>
stroke-emerald-300stroke: #6ee7b7;<div className="stroke-emerald-300"></div>
stroke-emerald-400stroke: #34d399;<div className="stroke-emerald-400"></div>
stroke-emerald-500stroke: #10b981;<div className="stroke-emerald-500"></div>
stroke-emerald-600stroke: #059669;<div className="stroke-emerald-600"></div>
stroke-emerald-700stroke: #047857;<div className="stroke-emerald-700"></div>
stroke-emerald-800stroke: #065f46;<div className="stroke-emerald-800"></div>
stroke-emerald-900stroke: #064e3b;<div className="stroke-emerald-900"></div>
stroke-emerald-950stroke: #022c22;<div className="stroke-emerald-950"></div>
stroke-teal-50stroke: #f0fdfa;<div className="stroke-teal-50"></div>
stroke-teal-100stroke: #ccfbf1;<div className="stroke-teal-100"></div>
stroke-teal-200stroke: #99f6e4;<div className="stroke-teal-200"></div>
stroke-teal-300stroke: #5eead4;<div className="stroke-teal-300"></div>
stroke-teal-400stroke: #2dd4bf;<div className="stroke-teal-400"></div>
stroke-teal-500stroke: #14b8a6;<div className="stroke-teal-500"></div>
stroke-teal-600stroke: #0d9488;<div className="stroke-teal-600"></div>
stroke-teal-700stroke: #0f766e;<div className="stroke-teal-700"></div>
stroke-teal-800stroke: #115e59;<div className="stroke-teal-800"></div>
stroke-teal-900stroke: #134e4a;<div className="stroke-teal-900"></div>
stroke-teal-950stroke: #042f2e;<div className="stroke-teal-950"></div>
stroke-cyan-50stroke: #ecfeff;<div className="stroke-cyan-50"></div>
stroke-cyan-100stroke: #cffafe;<div className="stroke-cyan-100"></div>
stroke-cyan-200stroke: #a5f3fc;<div className="stroke-cyan-200"></div>
stroke-cyan-300stroke: #67e8f9;<div className="stroke-cyan-300"></div>
stroke-cyan-400stroke: #22d3ee;<div className="stroke-cyan-400"></div>
stroke-cyan-500stroke: #06b6d4;<div className="stroke-cyan-500"></div>
stroke-cyan-600stroke: #0891b2;<div className="stroke-cyan-600"></div>
stroke-cyan-700stroke: #0e7490;<div className="stroke-cyan-700"></div>
stroke-cyan-800stroke: #155e75;<div className="stroke-cyan-800"></div>
stroke-cyan-900stroke: #164e63;<div className="stroke-cyan-900"></div>
stroke-cyan-950stroke: #083344;<div className="stroke-cyan-950"></div>
stroke-sky-50stroke: #f0f9ff;<div className="stroke-sky-50"></div>
stroke-sky-100stroke: #e0f2fe;<div className="stroke-sky-100"></div>
stroke-sky-200stroke: #bae6fd;<div className="stroke-sky-200"></div>
stroke-sky-300stroke: #7dd3fc;<div className="stroke-sky-300"></div>
stroke-sky-400stroke: #38bdf8;<div className="stroke-sky-400"></div>
stroke-sky-500stroke: #0ea5e9;<div className="stroke-sky-500"></div>
stroke-sky-600stroke: #0284c7;<div className="stroke-sky-600"></div>
stroke-sky-700stroke: #0369a1;<div className="stroke-sky-700"></div>
stroke-sky-800stroke: #075985;<div className="stroke-sky-800"></div>
stroke-sky-900stroke: #0c4a6e;<div className="stroke-sky-900"></div>
stroke-sky-950stroke: #082f49;<div className="stroke-sky-950"></div>
stroke-blue-50stroke: #eff6ff;<div className="stroke-blue-50"></div>
stroke-blue-100stroke: #dbeafe;<div className="stroke-blue-100"></div>
stroke-blue-200stroke: #bfdbfe;<div className="stroke-blue-200"></div>
stroke-blue-300stroke: #93c5fd;<div className="stroke-blue-300"></div>
stroke-blue-400stroke: #60a5fa;<div className="stroke-blue-400"></div>
stroke-blue-500stroke: #3b82f6;<div className="stroke-blue-500"></div>
stroke-blue-600stroke: #2563eb;<div className="stroke-blue-600"></div>
stroke-blue-700stroke: #1d4ed8;<div className="stroke-blue-700"></div>
stroke-blue-800stroke: #1e40af;<div className="stroke-blue-800"></div>
stroke-blue-900stroke: #1e3a8a;<div className="stroke-blue-900"></div>
stroke-blue-950stroke: #172554;<div className="stroke-blue-950"></div>
stroke-indigo-50stroke: #eef2ff;<div className="stroke-indigo-50"></div>
stroke-indigo-100stroke: #e0e7ff;<div className="stroke-indigo-100"></div>
stroke-indigo-200stroke: #c7d2fe;<div className="stroke-indigo-200"></div>
stroke-indigo-300stroke: #a5b4fc;<div className="stroke-indigo-300"></div>
stroke-indigo-400stroke: #818cf8;<div className="stroke-indigo-400"></div>
stroke-indigo-500stroke: #6366f1;<div className="stroke-indigo-500"></div>
stroke-indigo-600stroke: #4f46e5;<div className="stroke-indigo-600"></div>
stroke-indigo-700stroke: #4338ca;<div className="stroke-indigo-700"></div>
stroke-indigo-800stroke: #3730a3;<div className="stroke-indigo-800"></div>
stroke-indigo-900stroke: #312e81;<div className="stroke-indigo-900"></div>
stroke-indigo-950stroke: #1e1b4b;<div className="stroke-indigo-950"></div>
stroke-violet-50stroke: #f5f3ff;<div className="stroke-violet-50"></div>
stroke-violet-100stroke: #ede9fe;<div className="stroke-violet-100"></div>
stroke-violet-200stroke: #ddd6fe;<div className="stroke-violet-200"></div>
stroke-violet-300stroke: #c4b5fd;<div className="stroke-violet-300"></div>
stroke-violet-400stroke: #a78bfa;<div className="stroke-violet-400"></div>
stroke-violet-500stroke: #8b5cf6;<div className="stroke-violet-500"></div>
stroke-violet-600stroke: #7c3aed;<div className="stroke-violet-600"></div>
stroke-violet-700stroke: #6d28d9;<div className="stroke-violet-700"></div>
stroke-violet-800stroke: #5b21b6;<div className="stroke-violet-800"></div>
stroke-violet-900stroke: #4c1d95;<div className="stroke-violet-900"></div>
stroke-violet-950stroke: #2e1065;<div className="stroke-violet-950"></div>
stroke-purple-50stroke: #faf5ff;<div className="stroke-purple-50"></div>
stroke-purple-100stroke: #f3e8ff;<div className="stroke-purple-100"></div>
stroke-purple-200stroke: #e9d5ff;<div className="stroke-purple-200"></div>
stroke-purple-300stroke: #d8b4fe;<div className="stroke-purple-300"></div>
stroke-purple-400stroke: #c084fc;<div className="stroke-purple-400"></div>
stroke-purple-500stroke: #a855f7;<div className="stroke-purple-500"></div>
stroke-purple-600stroke: #9333ea;<div className="stroke-purple-600"></div>
stroke-purple-700stroke: #7e22ce;<div className="stroke-purple-700"></div>
stroke-purple-800stroke: #6b21a8;<div className="stroke-purple-800"></div>
stroke-purple-900stroke: #581c87;<div className="stroke-purple-900"></div>
stroke-purple-950stroke: #3b0764;<div className="stroke-purple-950"></div>
stroke-fuchsia-50stroke: #fdf4ff;<div className="stroke-fuchsia-50"></div>
stroke-fuchsia-100stroke: #fae8ff;<div className="stroke-fuchsia-100"></div>
stroke-fuchsia-200stroke: #f5d0fe;<div className="stroke-fuchsia-200"></div>
stroke-fuchsia-300stroke: #f0abfc;<div className="stroke-fuchsia-300"></div>
stroke-fuchsia-400stroke: #e879f9;<div className="stroke-fuchsia-400"></div>
stroke-fuchsia-500stroke: #d946ef;<div className="stroke-fuchsia-500"></div>
stroke-fuchsia-600stroke: #c026d3;<div className="stroke-fuchsia-600"></div>
stroke-fuchsia-700stroke: #a21caf;<div className="stroke-fuchsia-700"></div>
stroke-fuchsia-800stroke: #86198f;<div className="stroke-fuchsia-800"></div>
stroke-fuchsia-900stroke: #701a75;<div className="stroke-fuchsia-900"></div>
stroke-fuchsia-950stroke: #4a044e;<div className="stroke-fuchsia-950"></div>
stroke-pink-50stroke: #fdf2f8;<div className="stroke-pink-50"></div>
stroke-pink-100stroke: #fce7f3;<div className="stroke-pink-100"></div>
stroke-pink-200stroke: #fbcfe8;<div className="stroke-pink-200"></div>
stroke-pink-300stroke: #f9a8d4;<div className="stroke-pink-300"></div>
stroke-pink-400stroke: #f472b6;<div className="stroke-pink-400"></div>
stroke-pink-500stroke: #ec4899;<div className="stroke-pink-500"></div>
stroke-pink-600stroke: #db2777;<div className="stroke-pink-600"></div>
stroke-pink-700stroke: #be185d;<div className="stroke-pink-700"></div>
stroke-pink-800stroke: #9d174d;<div className="stroke-pink-800"></div>
stroke-pink-900stroke: #831843;<div className="stroke-pink-900"></div>
stroke-pink-950stroke: #500724;<div className="stroke-pink-950"></div>
stroke-rose-50stroke: #fff1f2;<div className="stroke-rose-50"></div>
stroke-rose-100stroke: #ffe4e6;<div className="stroke-rose-100"></div>
stroke-rose-200stroke: #fecdd3;<div className="stroke-rose-200"></div>
stroke-rose-300stroke: #fda4af;<div className="stroke-rose-300"></div>
stroke-rose-400stroke: #fb7185;<div className="stroke-rose-400"></div>
stroke-rose-500stroke: #f43f5e;<div className="stroke-rose-500"></div>
stroke-rose-600stroke: #e11d48;<div className="stroke-rose-600"></div>
stroke-rose-700stroke: #be123c;<div className="stroke-rose-700"></div>
stroke-rose-800stroke: #9f1239;<div className="stroke-rose-800"></div>
stroke-rose-900stroke: #881337;<div className="stroke-rose-900"></div>
stroke-rose-950stroke: #4c0519;<div className="stroke-rose-950"></div>

Overview of Stroke

Adding the Stroke

To style the stroke color of your SVGs, add the stroke-color-value utilities.

This is a live editor. Play around with it!
export default function TriangleSVG() {
  return (
    <svg
      className="w-screen h-screen stroke-blue-500"
      xmlns="http://www.w3.org/2000/svg"
      fill="none"
      viewBox="0 0 100 100"
      strokeWidth="4"
    >
      {/* Adding a stroke color */}
      <polygon points="50,15 90,85 10,85" />
    </svg>
  );
}

States and Responsiveness

Tailwind also allows you to dynamically add strokes. This categorically handles hover, focus, and breakpoint customization seamlessly.

Hover and Focus States

In scenarios where decorative SVGs are interactive, hover and focus states play a vital role in providing feedback to the user. Tailwind's pseudo-class functionality simplifies adding these states to strokes.

Consider this interactive SVG styled using hover and focus stroke utilities:

This is a live editor. Play around with it!
export default function InteractiveSVG() {
  return (
    <svg
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 100 100"
      className="w-screen h-screen stroke-gray-500 hover:stroke-green-500 focus:stroke-red-500"
      strokeWidth="6"
      tabIndex="0"
    >
      {/* States added on hover & focus */}
      <circle cx="50" cy="50" r="40" />
    </svg>
  );
}

Breakpoint Modifiers

Responsive SVG styling becomes straightforward with Tailwind's breakpoint modifiers, adapting strokes for varying screen sizes. By leveraging Tailwind's mobile-first breakpoint system, you can redefine the stroke properties for different device types.

Below is a responsive square SVG that alters its stroke dynamically between screen sizes:

This is a live editor. Play around with it!
export default function ResponsiveSVG() {
  return (
    <svg
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 100 100"
      className="w-screen h-screen stroke-purple-500 sm:stroke-green-500 lg:stroke-blue-500"
      strokeWidth="8"
    >
      {/* Breakpoints for stroke adjustments */}
      <rect x="10" y="10" width="80" height="80" />
    </svg>
  );
}

Custom Stroke

To cater to unique project themes, Tailwind provides option to extend its default stroke utilities. This ensures support for custom palettes and arbitrary values.

Extending the Theme

Incorporating custom colors or additional custom utilities can easily be achieved by editing Tailwind's configuration file (tailwind.config.js). This approach is suited for projects requiring an expanded or personalized color selection.

Below is an example demonstrating how to add a golden stroke through theme extension. Once the theme is extended, you can use the custom utility class (stroke-golden) in the code:

This is a live editor. Play around with it!
import tailwindConfig from "./tailwind.config.js";
tailwind.config = tailwindConfig;

export default function CustomStrokeSVG() {
  return (
    <svg
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 100 100"
      className="w-screen h-screen stroke-golden"
      strokeWidth="10"
    >
      {/* A triangle with custom golden stroke */}
      <polygon points="50,5 95,95 5,95" />
    </svg>
  );
}

Using Arbitrary Values

For scenarios requiring rapid experimentation or advanced customization outside Tailwind's design constraints, arbitrary value utilities provide a flexible mechanism. Use square brackets [] to directly input valid CSS color values for the stroke.

Here’s an SVG styled using arbitrary stroke values (with an experimental gradient):

This is a live editor. Play around with it!
export default function ArbitraryStrokeSVG() {
  return (
    <svg
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 100 100"
      className="w-screen h-screen stroke-[#36c4c5]"
      strokeWidth="5"
    >
      {/* Custom gradient stroke applied */}
      <defs>
        <linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="0%">
          <stop offset="0%" stopColor="#FF5733" />
          <stop offset="100%" stopColor="#FFC300" />
        </linearGradient>
      </defs>
      <circle cx="50" cy="50" r="40" />
    </svg>
  );
}

Real World Examples

WeatherIconsGrid

A weather dashboard showing different weather conditions with stroke-colored icons that change color on hover.

This is a live editor. Play around with it!
const WeatherIconsGrid = () => {
  const data = [
    { id: 1, icon: 'sun', label: 'Sunny', temp: '28°C' },
    { id: 2, icon: 'cloud', label: 'Cloudy', temp: '22°C' },
    { id: 3, icon: 'rain', label: 'Rainy', temp: '18°C' },
    { id: 4, icon: 'snow', label: 'Snowy', temp: '0°C' },
    { id: 5, icon: 'wind', label: 'Windy', temp: '20°C' },
    { id: 6, icon: 'storm', label: 'Storm', temp: '16°C' }
  ];

  return (
    <div className="grid grid-cols-3 gap-4 p-6 bg-slate-100 h-screen rounded-xl">
      {data.map((item) => (
        <div key={item.id} className="flex flex-col items-center p-4 bg-white rounded-lg group">
          <svg
            className="w-12 h-12 stroke-blue-500 group-hover:stroke-blue-700 transition-colors"
            viewBox="0 0 24 24"
            fill="none"
            strokeWidth="2"
            strokeLinecap="round"
            strokeLinejoin="round"
          >
            <path d="M12 3v18M3 12h18" />
          </svg>
          <span className="mt-2 font-medium">{item.label}</span>
          <span className="text-sm text-gray-600">{item.temp}</span>
        </div>
      ))}
    </div>
  );
};

export default WeatherIconsGrid

Timeline

A vertical timeline with status-based stroke colors for different states.

This is a live editor. Play around with it!
const Timeline = () => {
  const data = [
    { id: 1, event: 'Project Kickoff', date: 'Jan 2024', status: 'completed' },
    { id: 2, event: 'Design Phase', date: 'Feb 2024', status: 'completed' },
    { id: 3, event: 'Development', date: 'Mar 2024', status: 'in-progress' },
    { id: 4, event: 'Testing', date: 'Apr 2024', status: 'pending' },
    { id: 5, event: 'Deployment', date: 'May 2024', status: 'pending' },
    { id: 6, event: 'Review', date: 'Jun 2024', status: 'pending' }
  ];

  return (
    <div className="space-y-6 p-8">
      {data.map((item) => (
        <div key={item.id} className="flex items-center space-x-4">
          <svg
            className={`w-8 h-8 ${
              item.status === 'completed' ? 'stroke-green-500' :
              item.status === 'in-progress' ? 'stroke-blue-500' : 'stroke-gray-300'
            }`}
            viewBox="0 0 24 24"
            fill="none"
            strokeWidth="2"
          >
            <circle cx="12" cy="12" r="10" />
            {item.status === 'completed' && <path d="M8 12l3 3 5-5" />}
          </svg>
          <div>
            <h3 className="font-medium">{item.event}</h3>
            <p className="text-sm text-gray-600">{item.date}</p>
          </div>
        </div>
      ))}
    </div>
  );
};

export default Timeline;

SkillRadar

A skill assessment radar chart with colored strokes for different skill categories.

This is a live editor. Play around with it!
const SkillRadar = () => {
  const data = [
    { skill: "JavaScript", level: 90, category: "frontend" },
    { skill: "Python", level: 85, category: "backend" },
    { skill: "React", level: 88, category: "frontend" },
    { skill: "Node.js", level: 82, category: "backend" },
    { skill: "UI/UX", level: 75, category: "design" },
    { skill: "DevOps", level: 70, category: "operations" }
  ];

  const center = { x: 150, y: 150 };
  const radius = 100;

  const getCoordinates = (index, level) => {
    const angle = (Math.PI * 2 * index) / data.length;
    const adjustedRadius = (radius * level) / 100;
    return {
      x: center.x + adjustedRadius * Math.cos(angle),
      y: center.y + adjustedRadius * Math.sin(angle)
    };
  };

  return (
    <div className="p-8 bg-gray-50">
      <svg className="w-full h-96" viewBox="0 0 300 300">
        {/* Background grid */}
        {[20, 40, 60, 80, 100].map((level) => (
          <polygon
            key={level}
            points={data
              .map((_, i) => getCoordinates(i, level))
              .map(({ x, y }) => `${x},${y}`)
              .join(" ")}
            className="stroke-gray-200 fill-none"
          />
        ))}
        
        {/* Skill areas */}
        <polygon
          points={data
            .map((_, i) => getCoordinates(i, data[i].level))
            .map(({ x, y }) => `${x},${y}`)
            .join(" ")}
          className="stroke-purple-500 fill-purple-100 fill-opacity-50"
        />
        
        {/* Labels */}
        {data.map((skill, i) => {
          const { x, y } = getCoordinates(i, 100);
          return (
            <text
              key={skill.skill}
              x={x}
              y={y}
              className="text-xs"
              textAnchor="middle"
            >
              {skill.skill}
            </text>
          );
        })}
      </svg>
    </div>
  );
};

export default SkillRadar;

Skill Progress Circles

Circular progress indicators with stroke animations for skill levels.

This is a live editor. Play around with it!
export default function SkillProgress() {
  const skills = [
    { name: "JavaScript", level: 90 },
    { name: "React", level: 85 },
    { name: "Node.js", level: 80 },
    { name: "Python", level: 75 },
    { name: "Docker", level: 70 },
    { name: "AWS", level: 65 }
  ];

  return (
    <div className="grid grid-cols-3 gap-8 p-8">
      {skills.map((skill) => (
        <div key={skill.name} className="text-center">
          <svg className="w-32 h-32 mx-auto" viewBox="0 0 100 100">
            <circle
              className="stroke-gray-200"
              strokeWidth="8"
              cx="50"
              cy="50"
              r="40"
              fill="none"
            />
            <circle
              className="stroke-blue-500 transition-all duration-1000"
              strokeWidth="8"
              strokeLinecap="round"
              cx="50"
              cy="50"
              r="40"
              fill="none"
              strokeDasharray={`${skill.level * 2.51} 251`}
              transform="rotate(-90 50 50)"
            />
          </svg>
          <h3 className="mt-4 font-bold">{skill.name}</h3>
          <p className="text-gray-600">{skill.level}%</p>
        </div>
      ))}
    </div>
  );
}

SocialMediaGraph

A social media engagement graph with platform-specific stroke colors.

This is a live editor. Play around with it!
const SocialMediaGraph = () => {
  const data = [
    { platform: "Twitter", engagement: [45, 52, 38, 65, 42, 58], color: "stroke-blue-400" },
    { platform: "Instagram", engagement: [65, 72, 68, 75, 82, 88], color: "stroke-pink-500" },
    { platform: "LinkedIn", engagement: [35, 42, 48, 52, 58, 62], color: "stroke-blue-700" },
    { platform: "Facebook", engagement: [55, 48, 52, 45, 50, 54], color: "stroke-blue-600" },
    { platform: "YouTube", engagement: [25, 32, 38, 45, 52, 58], color: "stroke-red-500" },
    { platform: "TikTok", engagement: [15, 28, 42, 58, 72, 85], color: "stroke-purple-500" }
  ];

  const maxValue = Math.max(...data.flatMap(d => d.engagement));
  const width = 600;
  const height = 300;
  const padding = 40;

  return (
    <div className="p-8 bg-gray-50">
      <svg className="w-full h-96" viewBox={`0 0 ${width} ${height}`}>
        {data.map((platform, index) => {
          const points = platform.engagement.map((value, i) => {
            const x = padding + (i * (width - 2 * padding)) / (platform.engagement.length - 1);
            const y = height - padding - ((value / maxValue) * (height - 2 * padding));
            return `${x},${y}`;
          }).join(" ");

          return (
            <polyline
              key={platform.platform}
              points={points}
              className={`${platform.color} fill-none stroke-2`}
            />
          );
        })}
      </svg>
    </div>
  );
};

export default SocialMediaGraph;

Customization Examples

Animated Progress Circle with Custom Stroke

This example demonstrates a circular progress indicator with a customized stroke animation that changes color based on completion percentage.

This is a live editor. Play around with it!
import tailwindConfig from "./tailwind.config.js";
tailwind.config = tailwindConfig;

// App.js
export default function AnimatedProgressCircle() {
  return (
    <div className="flex items-center justify-center h-screen bg-gray-900">
      <svg className="w-48 h-48 transform rotate-[-90deg]">
        <circle
          cx="96"
          cy="96"
          r="88"
          className="stroke-gray-700 fill-none"
          strokeWidth="12"
        />
        <circle
          cx="96"
          cy="96"
          r="88"
          className="stroke-progress-high fill-none"
          strokeWidth="12"
          strokeDasharray="553"
          strokeDashoffset="166"
          strokeLinecap="round"
        />
      </svg>
    </div>
  )
}

Interactive Path Drawing with Custom Stroke

This example shows an interactive SVG path that responds to hover states with custom stroke properties.

This is a live editor. Play around with it!
import tailwindConfig from "./tailwind.config.js";
tailwind.config = tailwindConfig;

// App.js
export default function InteractivePath() {
  return (
    <div className="flex items-center justify-center h-screen bg-slate-100">
      <svg 
        viewBox="0 0 400 200" 
        className="w-96 h-48"
      >
        <path
          d="M10 80 Q 95 10 180 80 T 350 80"
          className="stroke-path-default hover:stroke-path-hover stroke-[3] fill-none transition-all duration-300 cursor-pointer"
          strokeLinecap="round"
          strokeLinejoin="round"
        />
        <path
          d="M10 120 Q 95 190 180 120 T 350 120"
          className="stroke-path-default hover:stroke-path-hover stroke-[3] fill-none transition-all duration-300 cursor-pointer"
          strokeLinecap="round"
          strokeLinejoin="round"
        />
      </svg>
    </div>
  )
}

Decorative Border Stroke Pattern

This example creates a decorative border pattern using SVG strokes with custom dash patterns and colors.

This is a live editor. Play around with it!
import tailwindConfig from "./tailwind.config.js";
tailwind.config = tailwindConfig;

// App.js
export default function DecorativeBorder() {
  return (
    <div className="flex items-center justify-center h-screen bg-white p-8">
      <div className="relative w-full max-w-md aspect-square">
        <svg 
          className="w-full h-full absolute top-0 left-0"
          viewBox="0 0 400 400"
        >
          <rect
            x="10"
            y="10"
            width="380"
            height="380"
            className="stroke-border-primary fill-none"
            strokeDasharray="20,10,5,10"
          />
          <rect
            x="30"
            y="30"
            width="340"
            height="340"
            className="stroke-border-secondary fill-none"
            strokeDasharray="10,5"
          />
        </svg>
        <img
          src="https://images.unsplash.com/photo-1682687220742-aba13b6e50ba"
          alt="Decorative content"
          className="absolute inset-12 object-cover"
        />
      </div>
    </div>
  )
}

Best Practices

Maintain Design Consistency

Establishing a consistent design language is a cornerstone of effective styling in any project. When applying stroke utilities in Tailwind CSS, ensure uniformity by leveraging a predefined color palette across all components.

Matching stroke colors to the project's theme not only improves aesthetics but also aids in intuitive navigation for end users. The use of Tailwind’s extend feature in tailwind.config.js allows for the addition of project-specific colors, ensuring all team members adhere to the same design guidelines.

For instance, when designing user interfaces with various SVG graphics, consistently using stroke-gray-500 for borders on inactive elements and stroke-blue-600 for active components creates a predictable experience. By coupling these utilities with hover and focus states, you can further enhance the application’s interactivity.

Optimize for Reusability

Reusability is key to scaling your components efficiently. Create Tailwind CSS utilities that apply consistent stroke styles to frequently used elements like icons, charts, or buttons. You can define custom classes in your Tailwind configuration file for reusable stroke widths and colors. For instance, you could create a utility class .stroke-primary to apply your brand’s signature stroke color throughout the project.

To enhance scalability, design components that adapt seamlessly to different contexts. For example, create a button component with customizable stroke styles based on Tailwind’s group-hover or focus utilities. This allows your components to accommodate varying use cases without needing significant modifications.

Accessibility Considerations

Enhance Readability and Navigability

SVG strokes in Tailwind CSS can improve the readability and structure of content by providing clear boundaries and outlines for important elements. This is especially useful for graphs, charts, and interactive elements where clarity is paramount. To enhance readability, apply high-contrast stroke utilities for elements like textual SVG outlines over imagery backgrounds.

Pair stroke properties with sufficient spacing to prevent overlapping or crowding, ensuring that the user’s attention is directed appropriately. Consistently applied strokes with clear transitions improve the navigation experience for all users, regardless of their device or environment.

Focus on High Contrast

Achieving optimal contrast is essential for users with low vision or color vision deficiencies. Tailwind's stroke utilities, coupled with a curated palette of accessible colors, help meet Web Content Accessibility Guidelines (WCAG). Using stroke-red-700 or stroke-yellow-900 alongside light backgrounds ensures sufficient contrast ratios for SVG graphics.

For components like icons or illustrations embedded in light-themed designs, use dark strokes (stroke-gray-800) for high visibility. Conversely, light strokes like stroke-gray-200 effectively enhance user interfaces featuring dark-mode aesthetics.

Conduct accessibility audits using browser extensions or tools like Lighthouse to confirm stroke visibility meets the necessary compliance thresholds. Tailwind’s custom configuration flexibility enables you to define accessibility-first designs by including readable, high-contrast stroke colors in your overarching theme.