Skip to content

Tailwind CSS

Lexicon ships a Tailwind preset that maps every design token to Tailwind utility classes. No manual theme configuration required.

Setup

Copy tailwind/lexicon-preset.js from the Lexicon repository into your project, then add it to your tailwind.config.js:

js
module.exports = {
  presets: [require('./lexicon-preset')],
  content: ['./src/**/*.{js,ts,jsx,tsx,html}'],
};

The preset extends (not replaces) the default Tailwind theme, so your existing utilities continue to work.

What the preset provides

Tailwind keyLexicon tokensExample utilities
colorsPurple scale, grey scale, statusbg-purple-500, text-grey-300, border-error
fontFamilyHeading, body, monofont-heading, font-body, font-mono
fontSizexs through 6xltext-xs, text-base, text-4xl
spacing0 through 32p-4 (16 px), gap-6 (24 px), m-8 (32 px)
borderRadiusnone through fullrounded-md, rounded-lg, rounded-full
boxShadowxs through xl, glow variantsshadow-md, shadow-glow-purple
transitionDurationfast, normal, slow, slowerduration-fast, duration-normal
transitionTimingFunctiondefault, springease-default, ease-spring

Usage examples

html
<!-- Card with Lexicon tokens -->
<div class="bg-grey-900 border border-grey-700 rounded-lg p-6 shadow-md">
  <h2 class="font-heading text-xl font-semibold text-white">
    Project title
  </h2>
  <p class="font-body text-base text-grey-300 mt-2">
    A brief description of the project.
  </p>
</div>

<!-- Button -->
<button class="bg-purple-500 hover:bg-purple-400 active:bg-purple-600 text-white font-medium rounded-lg px-5 py-2 transition-colors duration-normal ease-default">
  Save changes
</button>

<!-- Status badges -->
<span class="bg-success/10 text-success text-xs font-medium px-2 py-0.5 rounded-full">
  Active
</span>

Combining with CSS variables

You can mix Tailwind utilities and CSS custom properties when needed:

html
<div class="p-6 rounded-lg" style="background: var(--bg-surface-2)">
  Content
</div>

Importing the CSS alongside Tailwind

If you need the lex-* component classes in addition to Tailwind utilities, import the Lexicon stylesheet in your CSS entry:

css
@tailwind base;
@tailwind components;
@tailwind utilities;

@import './path/to/lexicon.css';

This gives you both Tailwind utilities (token-aligned) and Lexicon component classes (.lex-button, .lex-card, etc.).

Released under the MIT License. A product by the pace.