Use Case · Alpine.js

Last reviewed: March 2026

Alpine.js to Figma —
Every State Captured

Converting Alpine.js components to Figma is particularly direct because Alpine enriches HTML in place — there's no virtual DOM, no build step, and no compiled output. Trigger the state you want in the browser, copy the outerHTML from DevTools, paste into html2design, and get native Figma layers representing exactly that UI state.

What is "Alpine.js to Figma"?

"Alpine.js to Figma" refers to capturing the rendered state of an Alpine.js-powered component — a dropdown, modal, accordion, tab panel, or form with validation states — and importing it into Figma as a native, editable design frame. Alpine.js is a lightweight JavaScript framework that adds interactivity directly to HTML using x-data, x-show, x-bind, and other directives — without a build step or virtual DOM.

Because Alpine.js modifies the actual DOM directly, every interactive state is visible in the browser's DevTools Elements panel. The html2design Figma plugin accepts that rendered HTML — captured at any state — and converts it into native Figma frames. Alpine's directives ( x-data, x-show) are HTML attributes that don't affect the CSS rendering — the plugin reads computed CSS values and ignores the directives.

The Alpine.js to Figma workflow

Four steps. Works with Alpine.js 3+, any backend (Laravel, PHP, Django, Rails), and any CSS approach (Tailwind, plain CSS, Bootstrap).

Step 01

Open the page and trigger the target state

Open your page in a browser — localhost, staging, or production. Navigate to the component you want to capture and trigger the specific state you want in Figma: open the dropdown menu, expand the accordion panel, select a tab, open the modal, or fill the form.

Alpine.js updates the DOM directly when state changes — there's no re-render cycle or virtual DOM diffing. What you see in the browser is exactly what's in the Elements panel. Each state you want in Figma requires its own copy — capture the open state and the closed state separately.

Step 02

Copy the rendered HTML from DevTools

Open DevTools (F12) while the component is in the desired state. Find the component's root element in the Elements panel — the element with x-data is usually the root.

Right-click the element → Copy > Copy outerHTML. The copied HTML will include the current state — open dropdown items will be visible, active tab panels will be present, and x-show elements will have their current display value.

Step 03

Paste into html2design and generate Figma layers

Open Figma, run the HTML to Figma plugin, paste the copied HTML, and click Generate. Alpine's x-data, x-bind, and x-show attributes are HTML attributes — the plugin reads the computed CSS values, not the directives, so the import process is identical to any plain HTML component.

If your Alpine components use Tailwind CSS, all utility classes are resolved to pixel values. If you use plain CSS or a CSS framework, the browser resolves those too. You get a native Figma frame representing the exact visual state you captured.

Step 04

Build a state library in Figma

Alpine components often have multiple interactive states — default, open, error, loading, empty. Import each state as a separate Figma frame, then use Figma Components and Variants to organize them under a single component with named states. Your designer gets the full interaction spec directly from the live code.

For Alpine components that appear across multiple pages (navigation, modals, toast notifications), import from one page and use the Figma Component across the rest of the file — keeping the design documentation DRY and consistent.

Alpine.js-specific tips for better Figma output

Alpine.js's direct DOM manipulation gives you precise control over what state you capture. Here's how to get the most from it.

Capture each component state as a separate Figma frame

Alpine components often have 3–5 meaningful states: default, hover, focus, active, error, loading, empty. Trigger each state in the browser and paste into html2design separately. You'll build a set of Figma frames that become Variants when you convert them to a Figma Component — giving your design system a complete interactive spec derived directly from the live component.

Use DevTools Console to force a state

To capture a specific Alpine state without manually triggering it through the UI, use the DevTools Console. Select the Alpine component element in the Elements panel, then in the Console run: $el._x_dataStack[0].open = true (adjusting the property name to match your x-data definition). Alpine will immediately update the DOM to that state — then copy the outerHTML.

Alpine + Tailwind: perfect pairing for Figma

Alpine.js and Tailwind CSS are commonly used together — Alpine for interactivity, Tailwind for styling. This combination imports exceptionally cleanly: Tailwind utilities resolve to exact pixel values, and Alpine's state toggling (adding/removing Tailwind classes with x-bind:class) is reflected in the computed CSS at the moment you copy. Each state captures its actual applied classes.

Works with any server-rendered backend

Alpine.js is popular with Laravel Blade, Livewire, PHP templates, Django, and Rails views — any backend that renders HTML server-side. html2design doesn't care what generated the HTML: open the rendered page in a browser, trigger the Alpine state you want, copy outerHTML from DevTools. The backend framework is completely transparent to the import process.

Why Alpine.js imports are especially accurate in Figma

Alpine's direct DOM mutation model means the DevTools always shows the exact current state — no virtual DOM, no diffing lag.

No virtual DOM — the DOM is always current

Alpine.js manipulates the real DOM directly, not a virtual DOM representation. When Alpine toggles a class or shows/hides an element, DevTools shows the change immediately. There's no reconciliation lag or hydration delay — copy the outerHTML at any moment and get the precise current state.

No build step required

Alpine.js loads from a CDN <script> tag — no Node.js, no npm, no build process needed to run the page. You can capture Alpine components directly from staging, production, or any URL without setting up a local dev environment.

x-bind:class changes are captured accurately

Alpine's x-bind:class conditionally adds or removes CSS classes based on state. When you copy outerHTML, the element's class attribute reflects the current state. The browser resolves the applied classes to computed CSS values — so the Figma import shows the correct active, selected, or error styling.

Works with any backend or hosting

Alpine.js enhances server-rendered HTML from any backend. Import from your Laravel, Django, Rails, or PHP application running locally or from a staging URL — html2design captures whatever the browser renders, regardless of the stack behind it.

Frequently asked questions

How do I convert an Alpine.js component to Figma?

Open your page in a browser, trigger the component state you want (open dropdown, active tab, etc.), open DevTools (F12), find the component root element, right-click → Copy outerHTML, and paste into html2design in Figma. Alpine updates the real DOM directly — DevTools always reflects the current state.

How do I capture multiple Alpine states (open, closed, error)?

Trigger each state in the browser and paste each into html2design separately. You'll have multiple Figma frames — one per state. Convert them to Figma Component Variants to create a complete, interactive component spec for your design system.

Do Alpine.js directives (x-data, x-show) affect the Figma import?

No. Alpine directives are HTML attributes — html2design reads computed CSS values from the rendered DOM, not the HTML attributes. The directives are invisible to the import process. What matters is the current visual state: which elements are visible, which classes are applied, what the computed styles are.

Can I capture Alpine.js components from a Laravel or Django app?

Yes. Alpine.js is framework-agnostic — it works with any backend that renders HTML. Run your Laravel, Django, or Rails app locally, log in if needed, navigate to the page, and copy the outerHTML from DevTools. html2design captures the browser's output regardless of what backend generated the HTML.

Related Guides

Export your Alpine.js components to Figma today

Install html2design from the Figma Community — free to try, works with Alpine.js 3+, any backend, and any CSS framework.

Install Free on Figma Community

Free to try · $12/mo to unlock all features