Skip to content

matlab/agent-skills-playground / skills/matlab-uihtml-design

matlab-uihtml-design

Verified

Generate beautiful, distinctive HTML/CSS/JS control panels for MATLAB uihtml components. 8 built-in styles (Clean, Material, Cosmic Dark, Neumorphic Dark, Dashboard Light, Midnight Gradient, Minimal Mono, Warm Dark) plus custom aesthetics. Produces production-grade UI with sliders, buttons, toggles, and panels. Use when building visually polished MATLAB app UIs with uihtml.

assets/base-template-midnight-gradient.html

View on GitHub
<!DOCTYPE html>
<html data-theme="dark">
<head>
    <style>
        /* ===== THEME VARIABLES — Midnight Gradient ===== */

        :root {
            /* Light mode */
            --color-bg: #f8fafc;
            --color-surface: #FFFFFF;
            --color-surface-hover: #f1f5f9;
            --gradient-start: #2563eb;
            --gradient-end: #7c3aed;
            --color-accent: #4f46e5;
            --color-accent-glow: rgba(79, 70, 229, 0.2);
            --color-danger: #e11d48;
            --color-text-primary: #0f172a;
            --color-text-secondary: #475569;
            --color-text-muted: #94a3b8;
            --color-border: rgba(79, 70, 229, 0.15);
            --color-border-subtle: rgba(0, 0, 0, 0.06);

            --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
            --radius-card: 20px;
            --radius-btn: 12px;
            --transition-standard: 280ms cubic-bezier(0.4, 0, 0.2, 1);
        }

        [data-theme="dark"] {
            --color-bg: #0c0c14;
            --color-surface: #1a1a2e;
            --color-surface-hover: #222240;
            --gradient-start: #3b82f6;
            --gradient-end: #8b5cf6;
            --color-accent: #6366f1;
            --color-accent-glow: rgba(99, 102, 241, 0.3);
            --color-danger: #f43f5e;
            --color-text-primary: #f1f5f9;
            --color-text-secondary: #94a3b8;
            --color-text-muted: #475569;
            --color-border: rgba(99, 102, 241, 0.2);
            --color-border-subtle: rgba(255, 255, 255, 0.06);
        }

        /* ===== BASE STYLES ===== */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: var(--font-family);
            background: var(--color-bg);
            color: var(--color-text-primary);
            padding: 20px;
            height: 100vh;
            overflow-y: auto;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }

        ::-webkit-scrollbar { width: 4px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb {
            background: var(--color-border);
            border-radius: 2px;
        }

        /* ===== LAYOUT ===== */
        .controls-container {
            display: flex;
            flex-direction: column;
            gap: 16px;
            max-width: 420px;
            margin: 0 auto;
        }

        .panel {
            background: var(--color-surface);
            border-radius: var(--radius-card);
            padding: 20px;
            border: 1px solid var(--color-border);
            box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3),
                        0 0 1px rgba(99, 102, 241, 0.1);
            animation: fadeFloatIn 0.5s ease-out both;
            transition: border-color 250ms ease, box-shadow 250ms ease;
        }

        .panel:hover {
            border-color: rgba(99, 102, 241, 0.35);
        }

        .panel:nth-child(2) { animation-delay: 0.08s; }
        .panel:nth-child(3) { animation-delay: 0.16s; }
        .panel:nth-child(4) { animation-delay: 0.24s; }

        .section-label {
            font-size: 11px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            color: var(--color-text-secondary);
            margin-bottom: 14px;
        }

        /* ===== BUTTONS ===== */
        .button-group {
            display: flex;
            gap: 10px;
        }

        .btn {
            padding: 12px 24px;
            font-size: 14px;
            font-weight: 600;
            border: none;
            border-radius: var(--radius-btn);
            cursor: pointer;
            transition: all var(--transition-standard);
        }

        .btn:active {
            transform: translateY(0) scale(0.98);
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
            color: #FFFFFF;
            box-shadow: 0 4px 16px var(--color-accent-glow);
        }

        .btn-primary:hover {
            box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
            transform: translateY(-1px);
        }

        .btn-secondary {
            background: rgba(255, 255, 255, 0.03);
            color: var(--color-text-primary);
            border: 1px solid var(--color-border);
        }

        .btn-secondary:hover {
            background: rgba(255, 255, 255, 0.06);
            border-color: rgba(99, 102, 241, 0.4);
        }

        /* ===== SLIDERS ===== */
        .slider-group {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .slider-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .slider-label {
            font-size: 14px;
            font-weight: 400;
            letter-spacing: 0.1px;
            color: var(--color-text-secondary);
        }

        .slider-value {
            font-size: 14px;
            font-weight: 600;
            color: var(--color-text-primary);
            font-variant-numeric: tabular-nums;
        }

        input[type="range"] {
            -webkit-appearance: none;
            width: 100%;
            height: 4px;
            border-radius: 2px;
            background: var(--color-border-subtle);
            outline: none;
            cursor: pointer;
        }

        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
            box-shadow: 0 0 12px var(--color-accent-glow);
            cursor: pointer;
            transition: all 150ms ease;
        }

        input[type="range"]:hover::-webkit-slider-thumb {
            transform: scale(1.15);
            box-shadow: 0 0 18px rgba(99, 102, 241, 0.5);
        }

        input[type="range"]:active::-webkit-slider-thumb {
            transform: scale(1.25);
        }

        input[type="range"]::-moz-range-thumb {
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
            border: none;
            box-shadow: 0 0 12px var(--color-accent-glow);
        }

        /* ===== TOGGLES ===== */
        .toggle-group {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .toggle-label {
            font-size: 14px;
            font-weight: 400;
            color: var(--color-text-primary);
        }

        .toggle {
            width: 48px;
            height: 26px;
            border-radius: 13px;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid var(--color-border-subtle);
            position: relative;
            cursor: pointer;
            transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
            flex-shrink: 0;
        }

        .toggle.active {
            background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
            border-color: transparent;
            box-shadow: 0 0 12px var(--color-accent-glow);
        }

        .toggle::after {
            content: '';
            position: absolute;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--color-text-secondary);
            top: 2px;
            left: 2px;
            transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
        }

        .toggle.active::after {
            transform: translateX(22px);
            background: #FFFFFF;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        }

        /* ===== ANIMATIONS ===== */
        @keyframes fadeFloatIn {
            from {
                opacity: 0;
                transform: translateY(12px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* ===== FOCUS-VISIBLE (keyboard) — uihtml design guardrails ===== */
        .btn:focus-visible,
        .toggle:focus-visible {
            outline: 2px solid var(--color-accent, var(--accent-secondary, var(--color-primary, var(--md-primary, Highlight))));
            outline-offset: 2px;
        }
        input[type="range"]:focus-visible::-webkit-slider-thumb {
            box-shadow: 0 0 0 3px var(--color-accent, var(--accent-secondary, var(--color-primary, var(--md-primary, Highlight))));
        }
        input[type="range"]:focus-visible::-moz-range-thumb {
            box-shadow: 0 0 0 3px var(--color-accent, var(--accent-secondary, var(--color-primary, var(--md-primary, Highlight))));
        }

        /* ===== REDUCED MOTION — uihtml design guardrails ===== */
        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
                scroll-behavior: auto !important;
            }
        }
    </style>

    <script type="text/javascript">
        // ===== MATLAB UIHTML INTEGRATION =====

        function handleToggleKey(event) {
            if (event.key === ' ' || event.key === 'Enter') {
                event.preventDefault();
                event.currentTarget.click();
            }
        }

        function setup(htmlComponent) {
            window.htmlComponent = htmlComponent;

            htmlComponent.addEventListener("UpdateValues", function(event) {
                const data = event.Data;
            });

            htmlComponent.addEventListener("SetTheme", function(event) {
                document.documentElement.setAttribute('data-theme', event.Data.theme);
            });

            sendState();
        }

        // ===== STATE MANAGEMENT =====

        let state = {
            slider1: 50,
            toggle1: false
        };

        function sendState() {
            if (window.htmlComponent) {
                window.htmlComponent.sendEventToMATLAB("StateChange", state);
            }
        }

        // ===== COMPONENT HANDLERS =====

        function onSliderChange(name, value) {
            value = parseFloat(value);
            state[name] = value;

            const display = document.getElementById(name + "Value");
            if (display) {
                display.textContent = value.toFixed(1);
            }

            if (window.htmlComponent) {
                window.htmlComponent.sendEventToMATLAB("SliderChange", {
                    control: name,
                    value: value
                });
            }
        }

        function onToggle(name) {
            state[name] = !state[name];
            const el = document.getElementById(name);
            el.classList.toggle('active');
            el.setAttribute('aria-checked', el.classList.contains('active'));

            if (window.htmlComponent) {
                window.htmlComponent.sendEventToMATLAB("ToggleChange", {
                    control: name,
                    value: state[name]
                });
            }
        }

        function onButtonClick(action) {
            if (window.htmlComponent) {
                window.htmlComponent.sendEventToMATLAB("ButtonClick", {
                    action: action
                });
            }
        }

        // ===== THEME TOGGLE =====

        function toggleTheme() {
            const html = document.documentElement;
            const current = html.getAttribute('data-theme');
            const next = current === 'dark' ? 'light' : 'dark';
            html.setAttribute('data-theme', next);
            document.getElementById('themeToggle').setAttribute('aria-checked', next === 'dark');

            if (window.htmlComponent) {
                window.htmlComponent.sendEventToMATLAB("ThemeChange", { theme: next });
            }
        }
    </script>
</head>
<body>
    <div class="controls-container">

        <!-- Buttons Panel -->
        <div class="panel">
            <div class="section-label">Actions</div>
            <div class="button-group">
                <button class="btn btn-primary" onclick="onButtonClick('play')">Play</button>
                <button class="btn btn-secondary" onclick="onButtonClick('reset')">Reset</button>
            </div>
        </div>

        <!-- Slider Panel -->
        <div class="panel">
            <div class="section-label">Parameters</div>
            <div class="slider-group">
                <div class="slider-header">
                    <span class="slider-label">Speed</span>
                    <span id="slider1Value" class="slider-value">50.0</span>
                </div>
                <input type="range" id="slider1" min="0" max="100" step="0.1" value="50"
                       oninput="onSliderChange('slider1', this.value)">
            </div>
        </div>

        <!-- Toggle Panel -->
        <div class="panel">
            <div class="section-label">Options</div>
            <div class="toggle-group">
                <span class="toggle-label">Auto-rotate</span>
                <div id="toggle1" class="toggle" onclick="onToggle('toggle1')" tabindex="0" role="switch" onkeydown="handleToggleKey(event)" aria-checked="false"></div>
            </div>
        </div>

        <!-- Theme Toggle -->
        <div class="panel">
            <div class="section-label">Appearance</div>
            <div class="toggle-group">
                <span class="toggle-label">Dark Mode</span>
                <div id="themeToggle" class="toggle active" onclick="toggleTheme()" tabindex="0" role="switch" onkeydown="handleToggleKey(event)" aria-checked="true"></div>
            </div>
        </div>

    </div>
</body>
</html>
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall