Skip to content

Shadcn admin UI - #408

Merged
loic425 merged 43 commits into
mainfrom
shadcn-admin-ui
Nov 18, 2026
Merged

loic425 merged 43 commits into
mainfrom
shadcn-admin-ui

Conversation

@loic425

@loic425 loic425 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

rem42 and others added 30 commits November 6, 2026 15:53
camilleislasse and others added 8 commits November 14, 2026 14:56
Create shadcn admin ui based on bootstrap admin ui.

## Screenshots

### Login

![Login](https://raw.githubusercontent.com/rem42/Stack/d375274/docs/.gitbook/assets/shadcn-admin-ui-login.png)

### Dashboard

![Dashboard](https://raw.githubusercontent.com/rem42/Stack/d375274/docs/.gitbook/assets/shadcn-admin-ui-dashboard.png)

### Grid

![Grid](https://raw.githubusercontent.com/rem42/Stack/d375274/docs/.gitbook/assets/shadcn-admin-ui-list.png)

### Form

![Form](https://raw.githubusercontent.com/rem42/Stack/d375274/docs/.gitbook/assets/shadcn-admin-ui-form.png)


## Color themes

Interchangeable color themes, enabled in the bundle configuration (plain
CSS, no Tailwind rebuild needed):

```yaml
sylius_shadcn_admin_ui:
    themes: [zinc, blue]
```

Base colors: `stone`, `zinc`, `slate`. Accents: `blue`, `green`,
`orange`, `rose`, `violet`.

### No theme (neutral)
![Neutral
theme](https://raw.githubusercontent.com/rem42/Stack/e8811f5/docs/.gitbook/assets/shadcn-admin-ui-theme-default.png)

### `[zinc, blue]`
![zinc and blue
themes](https://raw.githubusercontent.com/rem42/Stack/e8811f5/docs/.gitbook/assets/shadcn-admin-ui-theme-zinc-blue.png)

### `[stone, orange]`
![stone and orange
themes](https://raw.githubusercontent.com/rem42/Stack/e8811f5/docs/.gitbook/assets/shadcn-admin-ui-theme-stone-orange.png)

### `[slate, violet]`
![slate and violet
themes](https://raw.githubusercontent.com/rem42/Stack/e8811f5/docs/.gitbook/assets/shadcn-admin-ui-theme-slate-violet.png)

### `[green]`
![green
theme](https://raw.githubusercontent.com/rem42/Stack/e8811f5/docs/.gitbook/assets/shadcn-admin-ui-theme-green.png)

### `[rose]`
![rose
theme](https://raw.githubusercontent.com/rem42/Stack/e8811f5/docs/.gitbook/assets/shadcn-admin-ui-theme-rose.png)
@loic425

loic425 commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@rem42 @camilleislasse
I'm just wondering if the name of the package should be "TailwindAdminUi" instead.
The bootstrap one is using Tabler internally and this Tailwind one is using Shadcn.

@loic425

loic425 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

@rem42 @camilleislasse I'm just wondering if the name of the package should be "TailwindAdminUi" instead. The bootstrap one is using Tabler internally and this Tailwind one is using Shadcn.

https://ux.symfony.com/toolkit#kits
On Symfony UX, we have "Bootstrap" & "Shadcn"... so!

Port of the BootstrapAdminUi auto mode (#407): the switcher opens a
Light / Dark / Auto menu, Auto follows prefers-color-scheme live and
across tabs, and is the default (no stored sylius-theme key).
| Q               | A
|-----------------|-----
| Branch?         | shadcn-admin-ui
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Related tickets | port of #407
| License         | MIT

The BootstrapAdminUi theme switcher got an auto mode in #407, but the
ShadcnAdminUi one still only toggles between light and dark: once
clicked, the OS preference is ignored for good.

The button now opens a shadcn `DropdownMenu` with three radio items:

- **Light** and **Dark** force the theme, as before.
- **Auto** follows `prefers-color-scheme`, live when the OS switches and
across open tabs.
- The button shows the icon of the selected mode (sun, moon or monitor),
and the selected item is checked.

Same storage as Bootstrap: Auto is the default and removes the
`sylius-theme` key, so admins who never picked a theme see no change and
those who did keep their choice. The inline script sets
`data-theme-mode` on `<html>` before the stylesheet, so there is no
flash and the right icon shows before Stimulus connects. The `toggle`
action is kept for overridden templates.

Labels reuse the `sylius.ui.theme_*` keys added to UiTranslations in
#407. `lucide:monitor` was added to the test app's locked icons.

| Light | Dark |
|-------|------|
| <img width="400" alt="Theme switcher with Light selected"
src="https://github.com/user-attachments/assets/e82a8b88-a590-40db-b821-fb4083dbf8d9"
/> | <img width="400" alt="Theme switcher with Dark selected"
src="https://github.com/user-attachments/assets/a4f02952-8d46-41ad-93cc-8369f0506618"
/> |

| Auto (OS light) | Auto (OS dark) |
|-----------------|----------------|
| <img width="400" alt="Theme switcher with Auto selected and a light
OS"
src="https://github.com/user-attachments/assets/2375d95d-7d64-4894-a3e2-5dea9a81d8b8"
/> | <img width="400" alt="Theme switcher with Auto selected and a dark
OS"
src="https://github.com/user-attachments/assets/65db64bb-d558-4459-9a98-5b8c34abbba4"
/> |
## Problem

`confirmation_modal` only renders a Cancel button. To confirm anything
that isn't the CSRF form of `delete_modal` (a Live action, a Stimulus
action, a form of the page), the whole `footer` block has to be
overridden: the Cancel button is copied, the confirm button rebuilt with
the right classes, and the dialog has to be closed by hand.

```twig
<twig:sylius_shadcn_admin_ui:confirmation_modal title="Archive this book?">
    <twig:block name="trigger">…</twig:block>
    <twig:block name="footer">
        <button type="button" class="{{ cancel_class }}" data-action="shadcn--alert-dialog#close">{{ 'sylius.ui.cancel'|trans }}</button>
        <button type="button" class="{{ confirm_class }}" data-action="shadcn--alert-dialog#close live#action" data-live-action-param="archive">Archive</button>
    </twig:block>
</twig:sylius_shadcn_admin_ui:confirmation_modal>
```

`button_class()` isn't visible inside the `<twig:…>` blocks either, so
the classes must be computed before the component.

## Solution

Three optional props. Without `confirm_label`, the footer is unchanged.

| Prop | Default | |
|---|---|---|
| `confirm_label` | `null` | Adds a confirm button next to Cancel |
| `confirm_variant` | `'default'` | Button variant; `destructive` uses
the same solid style as `delete_modal` |
| `confirm_attributes` | `{}` | Attributes of the button. Its
`data-action` runs after `shadcn--alert-dialog#close`, `type` defaults
to `button` |

Live action:

```twig
<twig:sylius_shadcn_admin_ui:confirmation_modal
    title="Archive this book?"
    confirm_label="Archive"
    confirm_variant="destructive"
    :confirm_attributes="{'data-action': 'live#action', 'data-live-action-param': 'archive'}"
>
    <twig:block name="trigger">
        <button type="button" {{ trigger_attributes }}>Archive</button>
    </twig:block>
</twig:sylius_shadcn_admin_ui:confirmation_modal>
```

Form of the page:

```twig
<twig:sylius_shadcn_admin_ui:confirmation_modal
    confirm_label="Publish"
    :confirm_attributes="{type: 'submit', form: 'publish-form'}"
>…</twig:sylius_shadcn_admin_ui:confirmation_modal>
```

The confirm button carries `data-test-confirm-button`, like the one of
`delete_modal`.

## Tests

`ConfirmationModalComponentTest`: default footer, Live action,
destructive variant, form submit. The ShadcnAdminUi suite passes (74
tests) after `importmap:install` and `tailwind:build`, as in the CI.
Implementation suggested from this comment:
#403 (review)

- "Admin panel" in sidebar.php goes through |trans but isn't a key, so
it's never translated. Maybe a sylius.ui.admin_panel key in
UiTranslations? ->
rem42@7f61b93
- Row "…" menu with the keyboard: focus stays on the trigger, arrows do
nothing, and with 2+ actions the second Tab closes the menu. I guess
because grid actions aren't DropdownMenu:Item. ->
rem42@76686f3
- dropdown.default() only reads text, icon and class from button, the
other Bootstrap options (disabled, icon_only, size...) are ignored. Not
used anywhere in the repo though. ->
rem42@119865c
- No JS test for the custom Stimulus controllers. Bootstrap has one for
its copy-to-clipboard controller (yarn test in CI), the shadcn copy
controller could get the same. ->
rem42@bfffaae
@loic425
loic425 merged commit 5110a83 into main Nov 18, 2026
7 checks passed
@loic425

loic425 commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Thx @rem42 and @camilleislasse for your great work 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants