datastar
БесплатноБез исполняемых скриптовНе проверенGuide for building interactive web UIs with Datastar and gomponents-datastar. Use this skill when adding frontend interactivity to Go web applications with…
от maragudk★ 49 звёзд на GitHubОб этом скилле
Datastar
Overview
Datastar is a lightweight frontend framework that enables backend-driven, interactive UIs through a hypermedia-first approach. It combines backend reactivity (similar to htmx) with frontend reactivity (like Alpine.js) using standard HTML data-* attributes.
When to Use This Skill
Use this skill when:
- Adding frontend interactivity to server-rendered HTML
- Building reactive UIs driven by backend state
- Using Datastar with gomponents in Go applications
- Working with Server-Sent Events (SSE) for real-time updates
Prerequisite: When using Datastar with Go, also use the gomponents skill for HTML component patterns.
Installation
Browser (CDN)
<script type="module" src="https://cdn.jsdelivr.net/gh/starfederation/[email protected]/bundles/datastar.js"></script>
Go (gomponents-datastar)
go get maragu.dev/gomponents-datastar
Part 1: Datastar Fundamentals
Core Concepts
Signals
Signals are reactive state containers. When a signal's value changes, all dependent expressions automatically update.
<div data-signals="{count: 0}">
<span data-text="$count"></span>
<button data-on:click="$count++">Increment</button>
</div>
- Signal names are prefixed with
$in expressions - Setting a signal to
nullorundefinedremoves it - Use dot-notation for nested signals:
$user.name
DOM Patching
Datastar uses morphing to update only changed DOM parts while preserving state. The backend sends HTML fragments that patch into the existing page.
Attributes Reference
State Management
data-signals - Initialize reactive signals:
<div data-signals="{name: 'World', count: 0}"></div>
data-computed - Create derived read-only signals:
<div data-computed="{doubled: $count * 2}"></div>
data-init - Run expressions when element loads:
<div data-init="console.log('Loaded')"></div>
Data Binding
data-text - Bind text content to an expression:
<span data-text="'Hello, ' + $name"></span>
data-bind - Two-way binding for form elements:
<input data-bind="$name" type="text">
data-show - Conditionally show/hide elements:
<div data-show="$isVisible">Only shown when true</div>
Styling
data-class - Conditionally apply CSS classes:
<div data-class="{'active': $isActive, 'error': $hasError}"></div>
data-style - Set inline styles dynamically:
<div data-style="{'color': $textColor, 'opacity': $opacity}"></div>
data-attr - Set HTML attributes dynamically:
<button data-attr="{'disabled': $isLoading}">Submit</button>
Events
data-on - Attach event listeners:
<button data-on:click="$count++">Click me</button>
<input data-on:input="$search = evt.target.value">
<form data-on:submit__prevent="@post('/submit')">
The evt variable references the event object.
data-on-intersect - Trigger when element enters viewport:
<div data-on-intersect="@get('/load-more')">Loading...</div>
data-on-interval - Run at regular intervals:
<div data-on-interval="$elapsed++">Timer: <span data-text="$elapsed"></span></div>
data-on-signal-patch - Execute when signals update:
<div data-on-signal-patch="console.log('Signals changed:', patch)"></div>
DOM Control
data-ref - Create signal referencing DOM element:
<input data-ref="$inputEl" type="text">
data-ignore - Exclude element from Datastar processing:
<div data-ignore>Third-party widget here</div>
data-ignore-morph - Keep Datastar active but skip morphing:
<div data-ignore-morph>Preserve this DOM structure</div>
data-preserve-attr - Preserve attributes during morphing:
<input data-preserve-attr="value" type="text">
Backend Actions
@get(), @post(), @put(), @patch(), @delete() - Send requests to backend:
<button data-on:click="@get('/api/data')">Load</button>
<button data-on:click="@post('/api/submit')">Submit</button>
Modifiers
Modifiers extend attribute behavior using double-underscore syntax:
Timing Modifiers
__debounce/__debounce_500ms- Debounce execution__throttle/__throttle_1s- Throttle execution__delay/__delay_200ms- Delay execution
Event Modifiers
__prevent- CallpreventDefault()__stop- CallstopPropagation()__capture- Use capture phase__passive- Mark as passive listener__once- Execute only once__self- Only trigger if target is the element itself__outside- Trigger when event occurs outside element__window- Attach listener to window
Example with Modifiers
<input data-on:input__debounce_300ms="@get('/search?q=' + $query)">
<button data-on:click__once="@post('/track-click')">Track</button>
<form data-on:submit__prevent="@post('/submit')">
Server-Sent Events (SSE)
Da
Установить datastar в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл datastar?
Guide for building interactive web UIs with Datastar and gomponents-datastar. Use this skill when adding frontend interactivity to Go web applications with Datastar attributes.
Как установить скилл datastar?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл datastar запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies 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…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic