-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
index.html
275 lines (244 loc) 路 8.47 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
---
title: "Angular integration"
date: 2021-04-29T16:00:58+02:00
draft: false
main_title: "Tailwind Elements Angular integration"
subheading: ""
seo_title: "Tailwind Elements integration with Angular - Free Examples & Tutorial"
description: "This article shows you how to integrate Angular application with Tailwind Elements. Free download, AGPL license."
image: "https://tecdn.b-cdn.net/img/components-big.jpg"
url: "docs/standard/integrations/angular-integration/"
menu:
integrations:
name: "Angular"
---
<!-- Section: Basic example -->
<section id="section-prerequisites">
<!-- Title -->
<h2
class="mb-5 mt-0 text-3xl font-semibold leading-normal"
id="prerequisites"
data-te-spy-item>
Prerequisites
</h2>
<!-- Description -->
<p class="mb-5">
Before starting the project make sure to install the following utilities:
</p>
<ul class="ml-4 list-disc">
<li>
<a
class="text-primary transition duration-150 ease-in-out hover:text-primary-600 focus:text-primary-600 active:text-primary-700 dark:text-primary-400 dark:hover:text-primary-500 dark:focus:text-primary-500 dark:active:text-primary-600"
href="https://nodejs.org/en/"
target="_blank"
>Node LTS</a
>
(14.x.x or higher recommended)
</li>
<li>
<a
class="text-primary transition duration-150 ease-in-out hover:text-primary-600 focus:text-primary-600 active:text-primary-700 dark:text-primary-400 dark:hover:text-primary-500 dark:focus:text-primary-500 dark:active:text-primary-600"
href="https://nodejs.org/en/"
target="_blank"
>Angular</a
>
(14.x.x or higher recommended)
</li>
<li>
Code editor. We recommend
<a
class="text-primary transition duration-150 ease-in-out hover:text-primary-600 focus:text-primary-600 active:text-primary-700 dark:text-primary-400 dark:hover:text-primary-500 dark:focus:text-primary-500 dark:active:text-primary-600"
href="https://code.visualstudio.com/"
target="_blank"
>VSCode</a
>
</li>
</ul>
<div
class="my-6 rounded-lg bg-primary-100 p-6 text-base text-info-800"
role="alert">
<p>
<strong>Angular Tailwind Elements:</strong>
<br />
Currently we are working on a standalone Angular version of Tailwind
Elements. If you want to know when it is going to be released, sign in in
our
<a
class="text-primary transition duration-150 ease-in-out hover:text-primary-600 focus:text-primary-600 active:text-primary-700 dark:text-primary-400 dark:hover:text-primary-500 dark:focus:text-primary-500 dark:active:text-primary-600"
href="/angular"
target="_blank"
>waiting list availabable here</a
>.
</p>
</div>
</section>
<hr class="my-5 dark:border-neutral-600" />
<!-- Section: Creating Angular app-->
<section id="section-angular-app">
<!-- Section title-->
<h2
class="mb-5 mt-0 text-3xl font-semibold leading-normal"
id="angular-application"
data-te-spy-item>
Creating a new Angular application
</h2>
<!-- Description -->
<p>
Let's create a fresh Angular application so that we can go through all the
steps together.
</p>
<h2 class="mt-5 text-lg font-bold">Step 1</h2>
<p class="mb-5">Install Angular CLI</p>
<div class="pb-4">
{{< twsnippet/wrapper "terminal" "" "mobile" >}}
{{< twsnippet/code active=true lang="plaintext" type="terminal" >}}
npm install -g @angular/cli
{{< /twsnippet/code >}}
{{< /twsnippet/wrapper >}}
</div>
<h2 class="text-lg font-bold">Step 2</h2>
<p class="mb-5">Create new project</p>
<div class="pb-4">
<!--prettier-ignore-->
{{< twsnippet/wrapper "terminal" "" "mobile" >}}
{{< twsnippet/code active=true lang="plaintext" type="terminal" >}}
ng new my-project
cd my-project
{{< /twsnippet/code >}}
{{< /twsnippet/wrapper >}}
</div>
</section>
<hr class="mb-5 dark:border-neutral-600" />
<!-- Creating and configuring Tailwind & Tailwind Elements-->
<section id="section-tailwind">
<!-- Section title-->
<h2
class="mb-5 mt-0 text-3xl font-semibold leading-normal"
id="tailwind"
data-te-spy-item>
Installing and configuring Tailwind CSS and Tailwind Elements
</h2>
<!-- Description -->
<h2 class="mt-5 text-lg font-bold">Step 1</h2>
<p class="mb-5">Install Tailwind CSS</p>
<div class="pb-4">
<!--prettier-ignore-->
{{< twsnippet/wrapper "terminal" "" "mobile" >}}
{{< twsnippet/code active=true lang="plaintext" type="terminal" >}}
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init
{{< /twsnippet/code >}}
{{< /twsnippet/wrapper >}}
</div>
<h2 class="text-lg font-bold">Step 2</h2>
<p class="mb-5">
Add the paths to all of your template files in your
<code>tailwind.config.cjs</code> file.
</p>
<div class="pb-4">
<!--prettier-ignore-->
{{< twsnippet/wrapper "tailwind.config.cjs" "" "mobile" >}}
{{< twsnippet/code active=true lang="JavaScript" >}}
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{html,ts}",
"./node_modules/tw-elements/dist/js/**/*.js"
],
theme: {
extend: {},
},
plugins: [require("tw-elements/dist/plugin")]
}
{{< /twsnippet/code >}}
{{< /twsnippet/wrapper >}}
</div>
<h2 class="text-lg font-bold">Step 3</h2>
<p class="mb-5">
Add the <code>@tailwind</code> directives for each of Tailwind鈥檚 layers to
your <code>./src/styles.css</code> file.
</p>
<div class="pb-4">
<!--prettier-ignore-->
{{< twsnippet/wrapper "styles.css" "" "mobile" >}}
{{< twsnippet/code active=true lang="CSS" >}}
@tailwind base;
@tailwind components;
@tailwind utilities;
{{< /twsnippet/code >}}
{{< /twsnippet/wrapper >}}
</div>
<h2 class="text-lg font-bold">Step 4</h2>
<p>Install Tailwind Elements.</p>
<div class="py-4">
<!--prettier-ignore-->
{{< twsnippet/wrapper "terminal" "" "mobile" >}}
{{< twsnippet/code active=true lang="plaintext" type="terminal" >}}
npm install tw-elements
{{< /twsnippet/code >}}
{{< /twsnippet/wrapper >}}
</div>
<h2 class="text-lg font-bold">Step 5</h2>
<p class="mb-5">
Import components which are you intend to use and necessary function
<code>initTE</code>. Initialize <code>initTE</code> in a lifecycle method.
</p>
<div class="pb-4">
<!--prettier-ignore-->
{{< twsnippet/wrapper "app.component.ts" "" "mobile" >}}
{{< twsnippet/code active=true lang="JavaScript" >}}
import { Datepicker, Input, initTE } from "tw-elements";
ngOnInit() {
initTE({ Datepicker, Input });
}
{{< /twsnippet/code >}}
{{< /twsnippet/wrapper >}}
</div>
</section>
<!--/Creating and configuring Tailwind & Tailwind Elements-->
<!-- Initializing via JS-->
<section id="section-initializing-js">
<!-- Title -->
<h2
class="mb-5 mt-0 text-3xl font-semibold leading-normal"
id="initializing-js"
data-te-spy-item>
Initializing via JS
</h2>
<!-- Description -->
<p class="mb-5">
By default all components have autoinit which means they are initialized by
data attributes. But if you want to make init by JavaScript - there is also
possibility to do that.
</p>
<h2 class="text-lg font-bold">Step 1</h2>
<p class="mb-5">Import components which are you intend to use.</p>
<div class="pb-4">
<!--prettier-ignore-->
{{< twsnippet/wrapper "app.component.ts" "" "mobile" >}}
{{< twsnippet/code active=true lang="JavaScript" >}}
import { Datepicker, Input } from "tw-elements";
{{< /twsnippet/code >}}
{{< /twsnippet/wrapper >}}
</div>
<h2 class="text-lg font-bold">Step 2</h2>
<p class="mb-5">Initialize components in lifecycle hook.</p>
<div class="pb-4">
<!--prettier-ignore-->
{{< twsnippet/wrapper "app.component.ts" "" "mobile" >}}
{{< twsnippet/code active=true lang="JavaScript" >}}
ngOnInit() {
const myInput = new Input(document.getElementById("myDatepicker"));
const options = {
format: "dd-mm-yyyy",
};
const myDatepicker = new Datepicker(
document.getElementById("myDatepicker"),
options
);
};
{{< /twsnippet/code >}}
{{< /twsnippet/wrapper >}}
</div>
</section>
<!-- /Initializing via JS-->