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-material.html

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

        :root {
            /* Light mode defaults (Purple seed) */
            --md-background: #FEF7FF;
            --md-surface: #FEF7FF;
            --md-surface-container: #F3EDF7;
            --md-surface-container-high: #ECE6F0;
            --md-primary: #6750A4;
            --md-primary-container: #EADDFF;
            --md-on-primary: #FFFFFF;
            --md-on-primary-container: #21005D;
            --md-secondary: #625B71;
            --md-secondary-container: #E8DEF8;
            --md-on-secondary-container: #1D192B;
            --md-tertiary: #7D5260;
            --md-error: #B3261E;
            --md-outline: #79747E;
            --md-outline-variant: #CAC4D0;
            --md-on-surface: #1D1B20;
            --md-on-surface-variant: #49454F;

            --font-family: 'Roboto Flex', 'Google Sans', Roboto, system-ui, sans-serif;
            --font-size-label-lg: 14px;
            --font-size-body-md: 14px;
            --font-size-body-sm: 12px;
            --font-size-title-md: 16px;
            --font-size-label-sm: 11px;

            --radius-sm: 8px;
            --radius-md: 12px;
            --radius-lg: 16px;
            --radius-full: 20px;

            --shadow-1: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.15);
            --shadow-2: 0 2px 6px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.3);

            --transition-standard: 300ms cubic-bezier(0.2, 0, 0, 1);
            --transition-fast: 150ms ease;
        }

        [data-theme="dark"] {
            --md-background: #141218;
            --md-surface: #141218;
            --md-surface-container: #211F26;
            --md-surface-container-high: #2B2930;
            --md-primary: #D0BCFF;
            --md-primary-container: #4F378B;
            --md-on-primary: #381E72;
            --md-on-primary-container: #EADDFF;
            --md-secondary: #CCC2DC;
            --md-secondary-container: #4A4458;
            --md-on-secondary-container: #E8DEF8;
            --md-tertiary: #EFB8C8;
            --md-error: #F2B8B5;
            --md-outline: #938F99;
            --md-outline-variant: #49454F;
            --md-on-surface: #E6E0E9;
            --md-on-surface-variant: #CAC4D0;

            --shadow-1: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
            --shadow-2: 0 2px 8px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.3);
        }

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

        body {
            font-family: var(--font-family);
            background: var(--md-background);
            color: var(--md-on-surface);
            padding: 16px;
            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(--md-outline-variant);
            border-radius: 2px;
        }

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

        .panel {
            background: var(--md-surface-container);
            border-radius: var(--radius-md);
            padding: 16px;
            transition: background 200ms ease, box-shadow 200ms ease;
            animation: fadeScaleIn 0.4s cubic-bezier(0.05, 0.7, 0.1, 1) both;
        }

        .panel:hover {
            background: var(--md-surface-container-high);
            box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        }

        .panel:nth-child(2) { animation-delay: 0.05s; }
        .panel:nth-child(3) { animation-delay: 0.1s; }
        .panel:nth-child(4) { animation-delay: 0.15s; }

        .section-label {
            font-size: var(--font-size-label-sm);
            font-weight: 500;
            letter-spacing: 0.5px;
            color: var(--md-on-surface-variant);
            margin-bottom: 12px;
        }

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

        .btn {
            padding: 10px 24px;
            font-size: var(--font-size-label-lg);
            font-weight: 500;
            letter-spacing: 0.1px;
            border: none;
            border-radius: var(--radius-full);
            height: 40px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            transition: all var(--transition-standard);
        }

        .btn::before {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: inherit;
            background: currentColor;
            opacity: 0;
            transition: opacity 200ms ease;
        }

        .btn:hover::before { opacity: 0.08; }
        .btn:active::before { opacity: 0.12; }
        .btn:active { transform: scale(0.98); }

        .btn-primary {
            background: var(--md-primary);
            color: var(--md-on-primary);
            box-shadow: var(--shadow-1);
        }

        .btn-primary:hover {
            box-shadow: var(--shadow-2);
        }

        .btn-secondary {
            background: var(--md-secondary-container);
            color: var(--md-on-secondary-container);
        }

        .btn-outlined {
            background: transparent;
            color: var(--md-primary);
            border: 1px solid var(--md-outline);
        }

        .btn-danger {
            background: var(--md-error);
            color: #FFFFFF;
        }

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

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

        .slider-label {
            font-size: var(--font-size-body-md);
            font-weight: 400;
            color: var(--md-on-surface-variant);
            letter-spacing: 0.25px;
        }

        .slider-value {
            font-size: var(--font-size-body-md);
            font-weight: 500;
            color: var(--md-primary);
            font-variant-numeric: tabular-nums;
        }

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

        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--md-primary);
            cursor: pointer;
            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
            transition: transform var(--transition-fast), box-shadow var(--transition-fast);
        }

        input[type="range"]:hover::-webkit-slider-thumb {
            box-shadow: 0 0 0 8px rgba(103, 80, 164, 0.12);
        }

        input[type="range"]:active::-webkit-slider-thumb {
            transform: scale(1.2);
            box-shadow: 0 0 0 12px rgba(103, 80, 164, 0.12);
        }

        input[type="range"]::-moz-range-thumb {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--md-primary);
            border: none;
            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
            cursor: pointer;
        }

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

        .toggle-label {
            font-size: var(--font-size-body-md);
            font-weight: 400;
            color: var(--md-on-surface);
            letter-spacing: 0.25px;
        }

        .switch {
            width: 52px;
            height: 32px;
            border-radius: 16px;
            background: var(--md-surface-container-high);
            border: 2px solid var(--md-outline);
            position: relative;
            cursor: pointer;
            transition: background var(--transition-standard), border-color var(--transition-standard);
            flex-shrink: 0;
        }

        .switch.active {
            background: var(--md-primary);
            border-color: var(--md-primary);
        }

        .switch::after {
            content: '';
            position: absolute;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--md-outline);
            top: 6px;
            left: 6px;
            transition: transform 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275),
                        width 300ms ease, height 300ms ease,
                        top 300ms ease, left 300ms ease,
                        background 300ms ease;
        }

        .switch.active::after {
            transform: translateX(20px);
            width: 24px;
            height: 24px;
            top: 2px;
            left: 2px;
            background: var(--md-on-primary);
        }

        /* ===== ANIMATIONS ===== */
        @keyframes fadeScaleIn {
            from {
                opacity: 0;
                transform: scale(0.92);
            }
            to {
                opacity: 1;
                transform: scale(1);
            }
        }

        /* ===== FOCUS-VISIBLE (keyboard) — uihtml design guardrails ===== */
        .btn:focus-visible,
        .switch:focus-visible {
            outline: 2px solid var(--color-accent, var(--md-primary, var(--color-primary, Highlight)));
            outline-offset: 2px;
        }
        input[type="range"]:focus-visible::-webkit-slider-thumb {
            box-shadow: 0 0 0 3px var(--color-accent, var(--md-primary, var(--color-primary, Highlight)));
        }
        input[type="range"]:focus-visible::-moz-range-thumb {
            box-shadow: 0 0 0 3px var(--color-accent, var(--md-primary, var(--color-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', state[name]);

            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);

            const themeToggle = document.getElementById('themeToggle');
            if (themeToggle) {
                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="switch" onclick="onToggle('toggle1')" tabindex="0" role="switch" aria-checked="false" onkeydown="handleToggleKey(event)"></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="switch active" onclick="toggleTheme()" tabindex="0" role="switch" aria-checked="true" onkeydown="handleToggleKey(event)"></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