You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/routes/docs/latest/tailwind-ui.svx
+23-16Lines changed: 23 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,26 @@ Many Tailwind UI examples use the [heroicons](https://heroicons.com/) icon libra
16
16
17
17
The React library uses a `.` in the names of many components: `Tab.Group`, `Listbox.Button`, etc. The Svelte library does not use this pattern and instead exports every component under its own name with no dot: `TabGroup`, `ListboxButton`, etc.
18
18
19
+
### Managing component state
20
+
21
+
A few components in this library use the `bind:` directive to bind data from the component. For example, a `Switch` has a `checked` prop which the component will modify when the Switch is toggled. As React does not have two-way binding, React code instead uses a `onChange` callback function.
22
+
23
+
```jsx
24
+
// React example
25
+
<Switch checked={enabled} onChange={setEnabled}>
26
+
// ...
27
+
</Switch>
28
+
```
29
+
30
+
becomes:
31
+
32
+
```svelte
33
+
<!-- Svelte equivalent -->
34
+
<Switch bind:checked={enabled}>
35
+
// ...
36
+
</Switch>
37
+
```
38
+
19
39
### `useState`
20
40
21
41
State declared with `useState` in React becomes just a normal variable in Svelte:
@@ -48,6 +68,8 @@ becomes
48
68
</Switch>
49
69
```
50
70
71
+
This is new in version 2.0 of this library. The previous version also used an event callback to set this data.
72
+
51
73
### JSX camelCased attribute names
52
74
53
75
In React, some HTML attributes have different names from the standard ones that are used in Svelte. These are covered in the [React documentation](https://reactjs.org/docs/dom-elements.html#differences-in-attributes), but we repeat the most important differences here:
@@ -119,21 +141,6 @@ In Svelte, you instead use the `on:` directive:
119
141
</Dialog>
120
142
```
121
143
122
-
Furthermore, in the React library, event handlers will be called with the their data directly:
0 commit comments