@@ -7,26 +7,24 @@ to change, or even change drastically.
7
7
Symfony UX Toolkit provides a set of ready-to-use kits for Symfony applications.
8
8
It is part of `the Symfony UX initiative `_.
9
9
10
- Kits are a nice way to begin a new Symfony application, by providing a set
11
- of `Twig components `_ (based on Tailwind CSS, but fully customizable depending
12
- on your needs).
10
+ Kits are a nice way to begin a new Symfony application, they contains
11
+ recipes to install nicely-crafter `Twig components `_ (already stylized,
12
+ but fully customizable depending on your needs) and more .
13
13
14
14
Please note that the **UX Toolkit is not a library of UI components **,
15
15
but **a tool to help you build your own UI components **.
16
16
It uses the same approach than the popular `Shadcn UI `_,
17
17
and a similar approach than `Tailwind Plus `_.
18
18
19
- After installing the UX Toolkit, you can start pulling the components you need
20
- from `UX Toolkit Kits `_, and use them in your project.
21
- They become **your own components **, and **you can customize them as you want **.
19
+ After installing the UX Toolkit, you can start installing the recipes you need
20
+ from `UX Toolkit Kits `_ and use them in your project.
21
+ Files created by the recipes become part of your project, and
22
+ you can customize them as you want.
22
23
23
24
Additionally, some `Twig components `_ use ``html_cva `` and ``tailwind_merge ``,
24
25
you can either remove them from your project or install ``twig/html-extra ``
25
26
and ``tales-from-a-dev/twig-tailwind-extra `` to use them.
26
27
27
- Also, we do not force you to use Tailwind CSS at all. You can use whatever
28
- CSS framework you want, but you will need to adapt the UI components to it.
29
-
30
28
Installation
31
29
------------
32
30
@@ -37,27 +35,25 @@ Install the UX Toolkit using Composer and Symfony Flex:
37
35
# The UX Toolkit is a development dependency:
38
36
$ composer require --dev symfony/ux-toolkit
39
37
40
- # If you want to keep `html_cva` and `tailwind_merge` in your Twig components:
41
- $ composer require twig/extra-bundle twig/html-extra:^3.12.0 tales-from-a-dev/twig-tailwind-extra
42
-
43
38
Usage
44
39
-----
45
40
46
- You may find a list of components in the `UX Components page `_ , with the installation instructions for each of them.
41
+ You may find a list of available kits in the `UX Toolkit Kits `_ page , with the installation instructions for each of them.
47
42
48
43
For example, if you want to install a `Button ` component, you will find the following instruction:
49
44
50
45
.. code-block :: terminal
51
46
52
47
$ php bin/console ux:install Button --kit=<kitName>
53
48
54
- It will create the ``templates/components/Button.html.twig `` file, and you will be able to use the `Button ` component like this:
49
+ It will create the ``templates/components/Button.html.twig `` file in your project,
50
+ and you will be able to use the `Button ` component like this:
55
51
56
52
.. code-block :: html+twig
57
53
58
54
<twig:Button>Click me</twig:Button>
59
55
60
- Create your own kit
56
+ Create your own Kit
61
57
-------------------
62
58
63
59
You have the ability to create and share your own kit with the community,
@@ -96,20 +92,55 @@ After creating your kit, the repository should have the following structure:
96
92
.. code-block :: text
97
93
98
94
.
99
- ├── docs
100
- │ └── components
101
- │ └── Button.twig
102
- ├── manifest.json
103
- └── templates
104
- └── components
105
- └── Button.html.twig
106
-
107
- A kit is composed of:
108
-
109
- - A ``manifest.json `` file, that describes the kit (name, description, dependencies, ...),
110
- - A ``templates/components `` directory, that contains the Twig components,
111
- - A ``assets `` directory, optional, that contains the assets (CSS, JS, Stimulus Controllers, ...) used by the components,
112
- - A ``examples `` directory, optional, that contains Twig code examples
95
+ ├── Button
96
+ │ ├── manifest.json
97
+ │ └── templates
98
+ │ └── components
99
+ │ └── Button.html.twig
100
+ └── manifest.json
101
+
102
+
103
+ A kit is described by a ``manifest.json `` file at the root directory, which contains the metadata of the kit:
104
+
105
+ .. code-block :: json
106
+
107
+ {
108
+ "$schema" : " ../vendor/symfony/ux-toolkit/schema-kit-v1.json" ,
109
+ "name" : " My UX Toolkit Kit" ,
110
+ "description" : " A custom kit for Symfony UX Toolkit." ,
111
+ "homepage" : " https://github/com/User/MyUxToolkitKit" ,
112
+ "license" : " MIT"
113
+ }
114
+
115
+ Then, a kit can contain one or more recipes. Each recipe is a directory
116
+ with a ``manifest.json `` file and some files to be copied into the project.
117
+
118
+ The ``manifest.json `` file of a recipe contains the metadata of the recipe:
119
+
120
+ .. code-block :: json
121
+
122
+ {
123
+ "$schema" : " ../vendor/symfony/ux-toolkit/schema-kit-recipe-v1.json" ,
124
+ "name" : " Button" ,
125
+ "description" : " A clickable element that triggers actions or events, supporting various styles and states." ,
126
+ "copy-files" : {
127
+ "templates/" : " templates/"
128
+ },
129
+ "dependencies" : {
130
+ {
131
+ "type" : " php" ,
132
+ "package" : " twig/extra-bundle"
133
+ },
134
+ {
135
+ "type" : " php" ,
136
+ "package" : " twig/html-extra:^3.12.0"
137
+ },
138
+ {
139
+ "type" : " php" ,
140
+ "package" : " tales-from-a-dev/twig-tailwind-extra"
141
+ }
142
+ }
143
+ }
113
144
114
145
Using your kit
115
146
~~~~~~~~~~~~~~
0 commit comments