Hudini Flat Section Header Component

A flat section header component without gradient overlays, with text stroke and auto-sizing, perfect for menus, panels and sections.

Flat Section Header Component

A flat section header component without gradient overlays, with text stroke and auto-sizing, perfect for menus, panels and sections.

Features

  • 📏 Auto-sizing: Automatically adjusts to text size + margin
  • 🎨 Flat Design: Clean, minimalist design without gradient overlays
  • âœī¸ Text Stroke: Text borders for better readability and visual impact
  • 🎨 Phaser Wind Integration: Uses design tokens for colors, sizes, borders and spacing
  • âš™ī¸ Fully Customizable: Control over font, colors, borders, stroke and spacing
  • 🔗 Fluent API: Method chaining support for easy customization

Props

  • text - Header text content
  • fontSize - Font size token ('xs', 'sm', 'base', 'lg', 'xl'...) or pixel value - default: 'lg'
  • font - Font family token ('primary', 'secondary', 'monospace', 'display') or CSS string - default: 'display'
  • backgroundColor - Background color token or CSS color - default: 'blue-600'
  • textColor - Text color token or CSS color - default: 'white'
  • borderRadius - Border radius token ('none', 'sm', 'md', 'lg', 'xl', 'full') or pixel value - default: 'md'
  • margin - Internal padding using spacing tokens ('0', '1', '2', '3', '4'...) or pixel value - default: '4'

Live Example

Loading game...

Usage Example

import Phaser from 'phaser';
import {
    Color,
    createTheme,
    HUDINI_KEY,
    HudiniPlugin,
    SceneWithHudini,
    FlatSectionHeader
} from 'hudini';

const theme = createTheme({});
type Theme = typeof theme;

class PreviewScene extends SceneWithHudini<Theme> {
    constructor() {
        super('preview');
    }

    create(): void {
        const { pw } = this.hudini;
        this.cameras.main.setBackgroundColor(pw.color.slate(900));

        // Create a simple flat section header
        const header = new FlatSectionHeader({
            scene: this,
            x: this.cameras.main.centerX,
            y: 150,
            text: 'Game Settings',
        });
        this.add.existing(header);

        // Create a custom styled header
        const customHeader = new FlatSectionHeader({
            scene: this,
            x: this.cameras.main.centerX,
            y: 250,
            text: 'Audio Settings',
            fontSize: 'xl',
            backgroundColor: 'green-600',
            textColor: 'white',
            borderRadius: 'lg',
            margin: '6',
        });
        this.add.existing(customHeader);
    }
}

Advanced Examples

Main Menu Header

const mainHeader = new FlatSectionHeader({
    scene: this,
    x: 400,
    y: 80,
    text: 'MAIN MENU',
    fontSize: 'xl',
    font: 'display',
    backgroundColor: 'slate-700',
    textColor: 'white',
    borderRadius: 'lg',
    margin: '6',
});

Pill Style Header

const pillHeader = new FlatSectionHeader({
    scene: this,
    x: 300,
    y: 200,
    text: '🏆 Achievements',
    fontSize: 'lg',
    backgroundColor: 'yellow-600',
    textColor: 'white',
    borderRadius: 'full',
    margin: '5',
});

Dynamic Updates with Method Chaining

const dynamicHeader = new FlatSectionHeader({
    scene: this,
    x: 400,
    y: 250,
    text: 'Dynamic Header',
});

// Customize using method chaining
dynamicHeader
    .setText('Updated Title')
    .setFontSize('2xl')
    .setBackgroundColor('purple-600')
    .setTextColor('white')
    .setBorderRadius('full')
    .setMargin('8');