Skip to main content
Glama

generate_tailwind_classes

Generate Tailwind utility classes for spacing, colors, typography, layout, or effects by specifying type and values to quickly apply consistent styles.

Instructions

Generate Tailwind utility classes for specific use cases

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYes
valuesNo

Implementation Reference

  • The handler function 'generateTailwindClasses' that dispatches to specialized class generators (spacing, colors, typography, layout, effects) based on the provided type.
    export const utilityTools = {
      generateTailwindClasses(type: string, values?: Record<string, any>): string {
        switch (type) {
          case "spacing":
            return this.generateSpacingClasses(values);
          case "colors":
            return this.generateColorClasses(values);
          case "typography":
            return this.generateTypographyClasses(values);
          case "layout":
            return this.generateLayoutClasses(values);
          case "effects":
            return this.generateEffectClasses(values);
          default:
            return "// Unknown type";
        }
      },
  • Helper 'generateSpacingClasses' returning Tailwind spacing utilities (padding, margin, gap) as a string template.
      generateSpacingClasses(_values?: Record<string, any>): string {
        const defaults = {
          padding: "p-4",
          margin: "m-2",
          gap: "gap-4",
        };
        const config = { ...defaults, ..._values };
    
        return `// Spacing utility classes
    const spacingClasses = {
      // Padding
      padding: '${config.padding}',
      paddingX: 'px-4',
      paddingY: 'py-4',
      paddingTop: 'pt-4',
      paddingRight: 'pr-4',
      paddingBottom: 'pb-4',
      paddingLeft: 'pl-4',
      
      // Margin
      margin: '${config.margin}',
      marginX: 'mx-auto',
      marginY: 'my-4',
      marginTop: 'mt-4',
      marginRight: 'mr-4',
      marginBottom: 'mb-4',
      marginLeft: 'ml-4',
      
      // Gap (for flex/grid)
      gap: '${config.gap}',
      gapX: 'gap-x-4',
      gapY: 'gap-y-4',
      
      // Space between (for flex children)
      spaceBetween: 'space-y-4',
      spaceX: 'space-x-4',
    };
    
    // Responsive spacing
    const responsiveSpacing = 'p-2 md:p-4 lg:p-6 xl:p-8';`;
      },
  • Helper 'generateColorClasses' returning Tailwind color utilities (background, text, border, gradients) as a string template.
      generateColorClasses(_values?: Record<string, any>): string {
        return `// Color utility classes
    const colorClasses = {
      // Background colors
      bgPrimary: 'bg-blue-500',
      bgSecondary: 'bg-gray-500',
      bgSuccess: 'bg-green-500',
      bgWarning: 'bg-yellow-500',
      bgError: 'bg-red-500',
      bgWhite: 'bg-white',
      bgBlack: 'bg-black',
      bgTransparent: 'bg-transparent',
      
      // Text colors
      textPrimary: 'text-blue-500',
      textSecondary: 'text-gray-500',
      textSuccess: 'text-green-500',
      textWarning: 'text-yellow-500',
      textError: 'text-red-500',
      textWhite: 'text-white',
      textBlack: 'text-black',
      textMuted: 'text-gray-400',
      
      // Border colors
      borderPrimary: 'border-blue-500',
      borderSecondary: 'border-gray-500',
      borderSuccess: 'border-green-500',
      borderWarning: 'border-yellow-500',
      borderError: 'border-red-500',
      borderGray: 'border-gray-300',
      
      // Gradient backgrounds
      gradientPrimary: 'bg-gradient-to-r from-blue-400 to-blue-600',
      gradientSecondary: 'bg-gradient-to-r from-gray-400 to-gray-600',
      gradientSuccess: 'bg-gradient-to-r from-green-400 to-green-600',
    };`;
      },
  • Helper 'generateTypographyClasses' returning Tailwind typography utilities (font size/weight, alignment, line height, decoration, transform) as a string template.
      generateTypographyClasses(_values?: Record<string, any>): string {
        return `// Typography utility classes
    const typographyClasses = {
      // Font sizes
      textXs: 'text-xs',
      textSm: 'text-sm',
      textBase: 'text-base',
      textLg: 'text-lg',
      textXl: 'text-xl',
      text2xl: 'text-2xl',
      text3xl: 'text-3xl',
      text4xl: 'text-4xl',
      text5xl: 'text-5xl',
      
      // Font weights
      fontThin: 'font-thin',
      fontLight: 'font-light',
      fontNormal: 'font-normal',
      fontMedium: 'font-medium',
      fontSemibold: 'font-semibold',
      fontBold: 'font-bold',
      fontExtrabold: 'font-extrabold',
      
      // Text alignment
      textLeft: 'text-left',
      textCenter: 'text-center',
      textRight: 'text-right',
      textJustify: 'text-justify',
      
      // Line height
      leadingNone: 'leading-none',
      leadingTight: 'leading-tight',
      leadingSnug: 'leading-snug',
      leadingNormal: 'leading-normal',
      leadingRelaxed: 'leading-relaxed',
      leadingLoose: 'leading-loose',
      
      // Text decoration
      underline: 'underline',
      noUnderline: 'no-underline',
      lineThrough: 'line-through',
      
      // Text transform
      uppercase: 'uppercase',
      lowercase: 'lowercase',
      capitalize: 'capitalize',
      normalCase: 'normal-case',
    };
    
    // Responsive typography
    const responsiveHeading = 'text-2xl md:text-3xl lg:text-4xl xl:text-5xl font-bold';
    const responsiveBody = 'text-sm md:text-base lg:text-lg';`;
      },
  • Helper 'generateLayoutClasses' returning Tailwind layout utilities (display, flexbox, grid, position, width/height, overflow) as a string template.
      generateLayoutClasses(_values?: Record<string, any>): string {
        return `// Layout utility classes
    const layoutClasses = {
      // Display
      block: 'block',
      inlineBlock: 'inline-block',
      inline: 'inline',
      flex: 'flex',
      inlineFlex: 'inline-flex',
      grid: 'grid',
      hidden: 'hidden',
      
      // Flexbox
      flexRow: 'flex-row',
      flexCol: 'flex-col',
      flexWrap: 'flex-wrap',
      flexNoWrap: 'flex-nowrap',
      itemsStart: 'items-start',
      itemsCenter: 'items-center',
      itemsEnd: 'items-end',
      justifyStart: 'justify-start',
      justifyCenter: 'justify-center',
      justifyEnd: 'justify-end',
      justifyBetween: 'justify-between',
      justifyAround: 'justify-around',
      justifyEvenly: 'justify-evenly',
      
      // Grid
      gridCols1: 'grid-cols-1',
      gridCols2: 'grid-cols-2',
      gridCols3: 'grid-cols-3',
      gridCols4: 'grid-cols-4',
      gridCols6: 'grid-cols-6',
      gridCols12: 'grid-cols-12',
      
      // Position
      relative: 'relative',
      absolute: 'absolute',
      fixed: 'fixed',
      sticky: 'sticky',
      
      // Width & Height
      wFull: 'w-full',
      hFull: 'h-full',
      wScreen: 'w-screen',
      hScreen: 'h-screen',
      minHScreen: 'min-h-screen',
      maxWScreen: 'max-w-screen-xl',
      
      // Overflow
      overflowHidden: 'overflow-hidden',
      overflowAuto: 'overflow-auto',
      overflowScroll: 'overflow-scroll',
    };
    
    // Common layout patterns
    const centerContent = 'flex items-center justify-center';
    const container = 'container mx-auto px-4';
    const responsiveGrid = 'grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4';`;
      },
  • Helper 'generateEffectClasses' returning Tailwind effect utilities (shadows, rounded corners, opacity, transitions, transforms, hover effects, cursor) as a string template.
      generateEffectClasses(_values?: Record<string, any>): string {
        return `// Effect utility classes
    const effectClasses = {
      // Shadows
      shadowSm: 'shadow-sm',
      shadow: 'shadow',
      shadowMd: 'shadow-md',
      shadowLg: 'shadow-lg',
      shadowXl: 'shadow-xl',
      shadow2xl: 'shadow-2xl',
      shadowNone: 'shadow-none',
      
      // Rounded corners
      roundedNone: 'rounded-none',
      roundedSm: 'rounded-sm',
      rounded: 'rounded',
      roundedMd: 'rounded-md',
      roundedLg: 'rounded-lg',
      roundedXl: 'rounded-xl',
      rounded2xl: 'rounded-2xl',
      roundedFull: 'rounded-full',
      
      // Opacity
      opacity0: 'opacity-0',
      opacity25: 'opacity-25',
      opacity50: 'opacity-50',
      opacity75: 'opacity-75',
      opacity100: 'opacity-100',
      
      // Transitions
      transitionAll: 'transition-all',
      transitionColors: 'transition-colors',
      transitionOpacity: 'transition-opacity',
      transitionShadow: 'transition-shadow',
      transitionTransform: 'transition-transform',
      duration150: 'duration-150',
      duration300: 'duration-300',
      duration500: 'duration-500',
      
      // Transforms
      scale50: 'scale-50',
      scale75: 'scale-75',
      scale100: 'scale-100',
      scale125: 'scale-125',
      scale150: 'scale-150',
      rotate45: 'rotate-45',
      rotate90: 'rotate-90',
      rotate180: 'rotate-180',
      
      // Hover effects
      hoverScale: 'hover:scale-105',
      hoverShadow: 'hover:shadow-lg',
      hoverOpacity: 'hover:opacity-80',
      
      // Cursor
      cursorPointer: 'cursor-pointer',
      cursorNotAllowed: 'cursor-not-allowed',
      cursorWait: 'cursor-wait',
    };
    
    // Common effect combinations
    const cardEffect = 'rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300';
    const buttonEffect = 'rounded-md shadow-sm hover:shadow-md transition-all duration-150';`;
      },
  • Zod schema 'GenerateTailwindClassesSchema' validating the tool input with type enum and optional values.
    const GenerateTailwindClassesSchema = z.object({
      type: z.enum(["spacing", "colors", "typography", "layout", "effects"]),
      values: z.record(z.any()).optional(),
    });
  • src/index.ts:232-245 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining name, description, and inputSchema for 'generate_tailwind_classes'.
    {
      name: "generate_tailwind_classes",
      description: "Generate Tailwind utility classes for specific use cases",
      inputSchema: {
        type: "object",
        properties: {
          type: {
            type: "string",
            enum: ["spacing", "colors", "typography", "layout", "effects"],
          },
          values: { type: "object" },
        },
        required: ["type"],
      },
  • src/index.ts:414-425 (registration)
    Tool call handler case in CallToolRequestSchema that parses args with Zod schema, calls utilityTools.generateTailwindClasses, and returns the result.
    case "generate_tailwind_classes": {
      const { type, values } = GenerateTailwindClassesSchema.parse(args);
      const classes = utilityTools.generateTailwindClasses(type, values);
      return {
        content: [
          {
            type: "text",
            text: classes,
          },
        ],
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It only says 'generate', implying creation, but doesn't state side effects, permissions, or output nature. As a generation tool, it likely doesn't mutate state, but this isn't clarified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no wasted words, but lacks details. It's brief but not effectively concise as it sacrifices informativeness. Front-loaded with main verb but otherwise minimal.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description doesn't describe return values, error behavior, or usage examples. For a tool with an enum and an object parameter, this is incomplete for an AI agent to use correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and the description does not explain any parameters. The enum for 'type' is self-explanatory but not elaborated, and 'values' (an object) is completely unexplained. No added meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description states 'Generate Tailwind utility classes for specific use cases' which is a generic purpose. It doesn't specify what kind of use cases or output format, and while it distinguishes from component-focused siblings like compose_components, it's still vague.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool vs alternatives like create_form or get_component_docs. No mention of prerequisites or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/its-just-ui/its-just-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server