# Symfony UX Demos

> Interactive demos showcasing Symfony UX components and features.

## UX Inspector

Inspect live components, follow their relationships and trace events directly in the browser.

Find a component on the page, inspect its props, follow its relationships and trace its events.

Tags: Stimulus, LiveComponent, Turbo

- [View demo](https://ux.symfony.com/inspector)

## Live Pagination

Add reactive filters and page changes to ordinary pagination links.

Combine [`Pagination`](/pagination) with [`LiveComponent`](/live-component)
                    for reactive filters and page changes. Each control remains an ordinary link,
                    and changing a filter returns you to the first page.

Tags: pagination, LiveComponent, filters, trait

- [View demo](https://ux.symfony.com/demos/pagination/live-pagination)

## Cursor Pagination

Move through ordered values without letting earlier changes shift the current slice.

Move through an ordered feed without a count query. The signed cursor records
                    a stable boundary, so an earlier deletion does not shift the current slice.

Tags: pagination, cursor, no-js

- [View demo](https://ux.symfony.com/demos/pagination/cursor-pagination)

## Pagination Themes

Render the same pages with a built-in theme or a focused Twig block override.

Render the same pagination result with the default bundle CSS,
                    Tailwind utility classes, or a focused application theme override.

Tags: pagination, Twig, themes, blocks

- [View demo](https://ux.symfony.com/demos/pagination/themes)

## Keep Files on Errors

A validation error empties a file input. Not this one.

One form, two file fields: a `FileType` and an [`UploadType`](/upload). Save it with an
                    empty title. The first field comes back empty. The second keeps its file, and the next
                    submit sends a few hundred bytes instead of the whole document.

Tags: upload, form, validation

- [View demo](https://ux.symfony.com/demos/upload/keep-files)

## Upload with Turbo

Save an album from a Turbo Frame. A Turbo Stream adds it to the page.

An [`UploadType`](/upload) form lives in a Turbo Frame. A validation error swaps only the frame, and the
                    photos stay. A valid album comes back as a Turbo Stream: added to the list, form reset,
                    no page reload.

Tags: upload, Turbo, gallery

- [View demo](https://ux.symfony.com/demos/upload/turbo)

## Live Avatar

Update a LiveComponent when the upload completes.

When an [`UploadType`](/upload) field completes its upload, the signed reference lands on an
                    `#[UploadTarget]` prop and the component renders again with the name and size
                    it received. No form submission, no page reload. The picture is the preview
                    of your browser: this public server keeps no file and sends none back.

Tags: upload, LiveComponent, avatar

- [View demo](https://ux.symfony.com/demos/upload/live-avatar)

## Simple & Enhanced Input

The compact field: a native input, or a list with previews and progress.

The compact layout of [`UploadType`](/upload), twice. On the left, the browser file input,
                    which uploads in the background. On the right, a list of files with thumbnails, progress,
                    and buttons to cancel, retry, or remove each transfer.

Tags: upload, compact, preview

- [View demo](https://ux.symfony.com/demos/upload/input)

## Dropzone & Card Grid

A large drop target, with a file list or a grid of image cards.

The dropzone layout of [`UploadType`](/upload): drop, paste, or click to browse. Without previews, files line up under
                    the target. With `show_preview`, each image becomes a card in a responsive grid.

Tags: upload, dropzone, gallery

- [View demo](https://ux.symfony.com/demos/upload/dropzone)

## Resumable Large Files

Pause a transfer, reload the page, and pick up where it stopped.

With [`UploadType`](/upload), large files travel in chunks, two at a time. Pause the transfer, or reload the
                    page halfway: selecting the same file again sends only the missing chunks.

Tags: upload, chunks, resume

- [View demo](https://ux.symfony.com/demos/upload/resumable)

## Turbo Infinite Scroll - 2/2

Load the next batch automatically with a lazy Turbo Frame.

Building on [Part One](/demos/turbo/infinite-scroll), this version loads the next batch when a `lazy Turbo Frame` enters the scrollable catalog; compare it with the [Live Component version](/demos/live-component/infinite-scroll-2), which uses a Live Component to load on scroll.

Tags: grid, pagination, loading, scroll

- [View demo](https://ux.symfony.com/demos/turbo/infinite-scroll-2)

## Turbo Infinite Scroll - 1/2

Append a batch of cards with a link and two Turbo Streams.

This demo explores the same product grid as the [Live Component version](/demos/live-component/infinite-scroll), using `Turbo Streams`: click `Load More` to append a batch of cards and replace the link with the next page.

Tags: grid, pagination, navigation

- [View demo](https://ux.symfony.com/demos/turbo/infinite-scroll)

## Removing a Component

Remove a LiveComponent after its final render, with an optional CSS exit animation.

Return `LiveResponse::remove()` from a [`LiveAction`](/live-component). LiveComponent renders once more, then removes the component root.
Style `[data-live-removing]` to animate the exit.

Tags: remove, animation, LiveAction, LiveResponse

- [View demo](https://ux.symfony.com/demos/live-component/live-remove)

## Downloading Files

Download from a route or send generated content while preserving state and events.

Return `LiveResponse::downloadUrl()` for a file served by its own route, or `LiveResponse::downloadFile()` for content built by a [`LiveAction`](/live-component).
LiveComponent renders state changes and delivers queued events before starting the download.

Tags: file, download, events, LiveAction

- [View demo](https://ux.symfony.com/demos/live-component/live-download)

## Infinite Scroll - 2/2

Automatically load more products on scroll with a Live Component and IntersectionObserver.

Building on [Part One](/demos/live-component/infinite-scroll), this version uses a Stimulus `IntersectionObserver` to call a Live Component action when the next item approaches the viewport, loading more products without a button.

Tags: grid, pagination, loading, scroll

- [View demo](https://ux.symfony.com/demos/live-component/infinite-scroll-2)

## Infinite Scroll - 1/2

Append product batches on demand with a Live Component while keeping existing cards in place.

Infinite scroll allows users to continuously load content as they scroll down the page.
`Part One` of this demo shows how to `append new items` to the page with a [`LiveComponent`](/live-component).

Tags: grid, pagination, navigation

- [View demo](https://ux.symfony.com/demos/live-component/infinite-scroll)

## Live Memory Card Game

A Memorable Game UX with Live Components!

A Memorable Game UX with Live Components! Discover how to use Live Components to create a game with a vibrant interface,
 rich interactions and real-time updates. This journey will take you through many features of Live Components, and you'll
  learn how to use them to create a fun and engaging game.

Tags: game, time, events, LiveAction

- [View demo](https://ux.symfony.com/demos/live-memory/)

## Auto-Validating Form

Create a form that validates each field in-real-time as the user enters data!

Enter a bad email or leave the password empty, and see how the
form validates in real time!

This renders a normal `Symfony` form but with extras added on top,
all generated from Symfony & Twig.

Tags: form, validation, inline

- [View demo](https://ux.symfony.com/demos/live-component/auto-validating-form)

## Embedded CollectionType Form

Create embedded forms with functional "add" and "remove" buttons all in Twig.

Unlock the potential of Symfony's [`CollectionType`](https://symfony.com/doc/current/reference/forms/types/collection.html) while writing zero JavaScript.
This demo shows off adding and removing items entirely in PHP & Twig.

Tags: form, collection

- [View demo](https://ux.symfony.com/demos/live-component/form-collection-type)

## Dependent Form Fields

After selecting the first field, automatically reload the options for a second field.

Unleash the power of form events, thanks to [`LiveComponent`](/live-component) and [`DynamicForms`](https://github.com/SymfonyCasts/dynamic-forms).

Tags: form, field, events

- [View demo](https://ux.symfony.com/demos/live-component/dependent-form-fields)

## Up & Down Voting

Save up & down votes live in pure Twig & PHP.

With each row as its own component, it's easy to add up & down voting + keep track of which items have been voted on.
This uses a [LiveAction](https://symfony.com/bundles/ux-live-component/current/index.html#actions) to save everything with Ajax.

Tags: form, LiveAction

- [View demo](https://ux.symfony.com/demos/live-component/voting)

## Inline Editing

Activate an inline editing form with real-time validation.

Inline editing? Simple. Use LiveComponents to track if you're in "edit" mode, let
the user update any fields on your entity, and save through a `LiveAction`.

Tags: form, inline, LiveAction

- [View demo](https://ux.symfony.com/demos/live-component/inline-edit)

## Auto-Updating Chart

Render & Update a Chart.js chart in real-time.

What do you get with Live Components + UX Chart.js + UX Autocomplete?

An auto-updating chart that you will ❤️.

Tags: chart, data, LiveAction, stimulus

- [View demo](https://ux.symfony.com/demos/live-component/chartjs)

## Invoice Creator

Create an invoice + line items that updates as you type.

Create or edit an `Invoice` entity along with child components for each related `InvoiceItem` entity.

Children components emit events to communicate to the parent and everything is saved in a `saveInvoice` LiveAction method.

Tags: form, entity, events, LiveAction

- [View demo](https://ux.symfony.com/demos/live-component/invoice)

## Product Form + Category Modal

Create a Category on the fly - from inside a product form - via a modal.

Open a child modal component to create a new Category.

Tags: form, entity, events, modal

- [View demo](https://ux.symfony.com/demos/live-component/product-form)

## Uploading files

Upload file from your live component through a LiveAction.

File uploads are tricky. Submit them to a `#[LiveAction]` with the `files` modifier
                on `data-live-action` then process them.

Tags: form, file, upload, LiveAction

- [View demo](https://ux.symfony.com/demos/live-component/upload)

