-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TwigBridge] add tailwindcss form layout #40449
Conversation
src/Symfony/Bridge/Twig/Resources/views/Form/form_tailwind_layout.html.twig
Outdated
Show resolved
Hide resolved
6b31fd6
to
26f0602
Compare
src/Symfony/Bridge/Twig/Resources/views/Form/tailwind_2_layout.html.twig
Outdated
Show resolved
Hide resolved
src/Symfony/Bridge/Twig/Resources/views/Form/tailwind_2_layout.html.twig
Outdated
Show resolved
Hide resolved
fd85ac3
to
aa6ac46
Compare
aa6ac46
to
c17df6e
Compare
c17df6e
to
c6240ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work! And nice work building the demo. I think we should roll with this 👍
One question is - due to the complex nature of form themes AND the special nature of Tailwind (where there is no 100% correct set of classes to use), we could consider making this Tailwind form theme experimental for one minor version (5.3).
I'm also very much in favour of marking as experimental in 5.3. This will give us time to see how it's used in the wild and refine as needed for 5.4. |
@kbond Can you add a comment at the beginning of the file to mark it as experimental? |
ad983a9
to
3719a40
Compare
Thank you @kbond. |
@kbond thank you for your PR, any attentions to contribute a form_theme for tailwindcss version 3 ? Cheers! |
@ahmed-bhs, is there anything that would have changed between 2 and 3? I think you could just use |
Greetings to all 😎 |
Closed issues are not the best place to ask for help. You can try to ask in GitHub Discussions tab, or on Slack Symfony Devs. In the mean time you can check this doc page https://symfony.com/doc/current/form/form_themes.html |
This PR was merged into the 5.4 branch. Discussion ---------- [Form] add tailwindcss form theme docs This is a rough 1st draft. Some questions: 1. Should we add more detailed installation instructions? My hope is there will eventually be offical encore docs on integrating tailwind we can link to. 2. Should I include the *out of the box* screenshot from the PR? 3. Should I include the *customization* demo (code/screenshot) from the PR? I'd appreciate some input/feedback! Closes #15160, Symfony PR: symfony/symfony#40449 Commits ------- 4947010 [Form] add tailwindcss form theme docs
Per @weaverryan's call to action on twitter and slack discussion.
It's been tricky to create a generic form layout for tailwind as it's a css utility framework and has an unlimited number of ways to style forms. With tailwindcss 2.0, the tailwind team released an official form plugin that provides form element reset/normalization that looks decent out of the box. This PR is an attempt to piggy-back on this plugin to provide a minimal Symfony form layout for tailwind. The goal is to have your forms look good in a tailwind/Symfony app with no customization (but of course allow customization as desired).
This layout requires tailwindcss 2 and the form plugin.
I followed the "unstyled" demo for the form plugin as a style guide. Here is a screenshot of this layout used in a demo Symfony app with several common form types (I'll try to keep this updated as I update the PR):

Some notes about the layout:
class="mt-1 mt-0"
,mt-1
"wins" asmt-1
comes later in the compiled stylesheet.row_class
,widget_class
,label_class
,help_class
,error_item_class
) to make it easier to extend and customize the layout. Note thewidget_disabled_class
/widget_errors_class
variables: these are added even if you've overridden thewidget_class
variable.Customization
Customizing is especially important for this layout. Here are the two ways:
Customization POC/Demo
With this custom form theme:
The above example looks like this:
