Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit 663d278

Browse files
committed
Update docs
1 parent 8036b85 commit 663d278

File tree

14 files changed

+170
-19
lines changed

14 files changed

+170
-19
lines changed

docs/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: v2
2+
title: v3
33
slogan: A set of Blade components for TailwindCSS forms.
44
githubUrl: https://github.com/rawilk/laravel-form-components
55
branch: master

docs/components/custom-select.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ custom option markup while still providing usability functionalities such as key
1212
## Installation
1313

1414
The custom select component requires Alpine.js, as well as some custom JavaScript written into the package to work.
15-
Ensure you have the proper [directives](/docs/laravel-form-components/v2/installation#directives) in your layout file.
15+
Ensure you have the proper [directives](/docs/laravel-form-components/v3/installation#directives) in your layout file.
1616
In production, we recommend you install and compile the JavaScript libraries before you deploy:
1717

18-
- [Alpine.js](https://github.com/alpinejs/alpine) `^2.7`
18+
- [Alpine.js](https://github.com/alpinejs/alpine) `^2.8`
1919

2020
## Basic Usage
2121

@@ -237,4 +237,4 @@ it is opened.
237237
## Addons
238238

239239
The custom select component supports leading addons, but since there are already elements appended to the end
240-
of the button trigger, trailing addons are not supported. For more information on addons, see [the input documentation](/docs/laravel-form-components/v2/components/input#addons).
240+
of the button trigger, trailing addons are not supported. For more information on addons, see [the input documentation](/docs/laravel-form-components/v3/components/input#addons).

docs/components/date-picker.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ By using it, you can simply add a date and/or time picker to your form with one
1010

1111
## Installation
1212

13-
While the `date-picker` component works out-of-the-box when you've [set the directives](/docs/laravel-form-components/v2/installation#directives),
13+
While the `date-picker` component works out-of-the-box when you've [set the directives](/docs/laravel-form-components/v3/installation#directives),
1414
we recommend that you install and compile the JavaScript libraries before you deploy to production:
1515

16-
- [Alpine.js](https://github.com/alpinejs/alpine) `^2.7`
16+
- [Alpine.js](https://github.com/alpinejs/alpine) `^2.8`
1717
- [Flatpickr](https://flatpickr.js.org/) `4.6.3`
1818

1919
Make sure you import flatpickr as `flatpickr` in your JavaScript, and make sure it's available globally:
@@ -157,4 +157,4 @@ For more information on the callbacks available, please consult [the events api]
157157
Like the other inputs, the date picker can also have leading and trailing addons, however by default you cannot add them.
158158
To add leading addons, you must disable the toggle icon, and for trailing addons, you must set `clearable` to `false`.
159159

160-
See the [input documentation](/docs/laravel-form-components/v2/components/input#addons) for more information.
160+
See the [input documentation](/docs/laravel-form-components/v3/components/input#addons) for more information.

docs/components/email.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ This will output:
2828
By default an `email` type will be set for the input field as well as an `id` that allows it to be
2929
easily referenced by a `label` element.
3030

31-
Besides this, the email element behaves exactly the same as the [input component](/docs/laravel-form-components/v2/components/input).
31+
Besides this, the email element behaves exactly the same as the [input component](/docs/laravel-form-components/v3/components/input).

docs/components/file-upload.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ as well just by adding a `wire:model` to the input.
1313
Even though the `file-upload` component will work out-of-the-box if you're using the script blade directives in your layout (`@fcScripts`),
1414
we recommend that you install and compile the JavaScript libraries before you deploy to production.
1515

16-
- [Alpine.js](https://github.com/alpinejs/alpine) `^2.7`
16+
- [Alpine.js](https://github.com/alpinejs/alpine) `^2.8`
1717

1818
## Basic Usage
1919

docs/components/filepond.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Before using this component, we recommend familiarizing yourself with the FilePo
1010

1111
## Installation
1212

13-
While the `file-pond` component works out-of-the-box when you've [set the directive](/docs/laravel-form-components/v2/installation#directives),
13+
While the `file-pond` component works out-of-the-box when you've [set the directive](/docs/laravel-form-components/v3/installation#directives),
1414
we recommend that you install and compile the JavaScript libraries before you deploy to production:
1515

16-
- [Alpine.js](https://github.com/alpinejs/alpine) `^2.7`
16+
- [Alpine.js](https://github.com/alpinejs/alpine) `^2.8`
1717
- [FilePond](https://pqina.nl/filepond/) `^4.21`
1818

1919
As per the [FilePond docs](https://pqina.nl/filepond/docs/patterns/installation/), you can install FilePond via npm:

docs/components/input.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ When there are errors for a field, the `aria-invalid` and `aria-describedby` att
8080
```
8181

8282
The actual error message won't be rendered from the input component itself, but it can be automatically rendered for you
83-
by wrapping the `<x-input />` component inside of a `<x-form-group />` component. Please refer to the [form-group documentation](/docs/laravel-form-components/v2/components/form-group#error-handling) for more information.
83+
by wrapping the `<x-input />` component inside of a `<x-form-group />` component. Please refer to the [form-group documentation](/docs/laravel-form-components/v3/components/form-group#error-handling) for more information.
8484

8585
The `aria-describedby` attribute takes the `name` attribute and appends `-error` to it, which will be the id given to the error message rendered by the `<x-form-group />` component. If you already have `aria-describedby` set on the input, the attribute
8686
value will be merged with the error attribute value.

docs/components/password.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ Like the other inputs, the password input can also have leading addons, but sinc
111111
includes a password toggle as a trailing icon addon, you are not able to add a trailing addon
112112
to the password input. If you need a trailing addon, you should use the input component instead.
113113

114-
See the [input documentation](/docs/laravel-form-components/v2/components/input#addons) for more information.
114+
See the [input documentation](/docs/laravel-form-components/v3/components/input#addons) for more information.

docs/components/select.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,5 @@ This will output:
173173

174174
## Reference
175175

176-
Since the select component extends the [input component](/docs/laravel-form-components/v2/components/input), you are able
176+
Since the select component extends the [input component](/docs/laravel-form-components/v3/components/input), you are able
177177
to do a lot of the same things you can with the input element, such as error handling and addons.

docs/components/switch-toggle.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Switch Toggle
3+
sort: 18
4+
---
5+
6+
## Introduction
7+
8+
The `switch-toggle` component offers an easy alternative to a traditional checkbox and is heavily based on
9+
the [Tailwind UI toggle component](https://tailwindui.com/components/application-ui/forms/toggles). The
10+
switch toggle acts like a checkbox, however it allows for an "off" value and an "on" value; see [custom on and off values](#custom-on-and-off-values)
11+
for more info.
12+
13+
## Installation
14+
15+
While the `switch-toggle` component works out-of-the-box when you've [set the directive](/docs/laravel-form-components/v3/installation#directives),
16+
we recommend that you install and compile the JavaScript libraries before you deploy to production:
17+
18+
- [Alpine.js](https://github.com/alpinejs/alpine) `^2.8`
19+
20+
## Basic Usage
21+
22+
The most basic usage of the component is just by calling it:
23+
24+
```html
25+
<x-switch-toggle />
26+
```
27+
28+
This will render a toggle element similar to the example shown for the "Simple toggle" on [Tailwind UI](https://tailwindui.com/components/application-ui/forms/toggles).
29+
30+
## Labels
31+
32+
You can easily add a label to the switch toggle by using the `label` attribute:
33+
34+
```html
35+
<x-switch-toggle label="Notifications on" />
36+
```
37+
38+
This will render a label containing the text "Notifications on" to the right side of the switch.
39+
40+
### Left aligned labels
41+
42+
You can also render labels on the left of switch by setting `label-position` to `left`:
43+
44+
```html
45+
<x-switch-toggle label="Notifications on" label-position="left" />
46+
```
47+
48+
Now "Notifications on" will be rendered to the left of the switch.
49+
50+
## Handling values
51+
52+
The switch toggle component offers support for both `wire:model` and `wire:model.defer` right out of the box, and is the recommended way
53+
to use this component when you are using Laravel Livewire. Behind-the-scenes, the component will use the `@entangle` blade directive
54+
from livewire to bind the value to a local variable on the component.
55+
56+
```html
57+
<x-switch-toggle wire:model.defer="allowNotifications" label="Notifications on" />
58+
```
59+
60+
For non-livewire forms, you may also give the component a `value` to use for the initial value, but be sure to include a `name` attribute so that your server
61+
can receive the value from the switch in a normal form submission.
62+
63+
```html
64+
<x-switch-toggle name="foo" :value="true" />
65+
```
66+
67+
When the component is given a name attribute, it will render a hidden input so that the current value of the component is passed on to the server via a form submission.
68+
The hidden input rendered from the example above will look like this:
69+
70+
```html
71+
<input type="hidden" name="foo" x-bind:value="JSON.stringify(value)" />
72+
```
73+
74+
### Custom on and off values
75+
76+
The switch toggle is not limited to `true` and `false` values for its respective "on" and "off" values; it can use strings and integer values as well:
77+
78+
```html
79+
<x-switch-toggle on-value="foo" off-value="bar" />
80+
```
81+
82+
Now when the switch is "off", the value will be "bar", and when it is "on", the value will be "foo".
83+
84+
## Variations
85+
86+
Different size and style variations of the switch may be rendered out-of-the-box:
87+
88+
### Short Toggle
89+
90+
Based on the [short toggle](https://tailwindui.com/components/application-ui/forms/toggles#component-b3e0a15571300f79fced5845f97fa972) example from
91+
Tailwind UI, the short toggle will make the size of the circle on the bar larger than the height of the bar. All you need to do for this style is set
92+
the `short` flag to `true`:
93+
94+
```html
95+
<x-switch-toggle short />
96+
```
97+
98+
### Sizing
99+
100+
Both the simple and short toggle variations allow for different sizing out-of-the-box. Simply pass in a `size` to the component to re-size it:
101+
102+
```html
103+
<x-switch-toggle size="lg" />
104+
```
105+
106+
Here are the sizes the package provides by default for each variation:
107+
108+
**Simple**:
109+
- sm
110+
- base (default)
111+
- lg
112+
113+
**Short**:
114+
- base (default)
115+
- lg
116+
117+
These sizes also come in responsive variants, so if you wanted the switch small on small screens, but large on larger screens, you could do something like this:
118+
119+
```html
120+
<x-switch-toggle class="switch-toggle--sm lg:switch-toggle--lg" />
121+
```
122+
123+
You are free to add your own sizes in your own stylesheets. Just reference the [switch toggle styles](https://github.com/rawilk/laravel-form-components/blob/master/resources/sass/utils/_switch.scss#L126) for guidance.
124+
125+
## Icons
126+
127+
Based on the [toggle with icon](https://tailwindui.com/components/application-ui/forms/toggles#component-bcaf782196186836b6ea686e7096e734) from Tailwind UI, the switch
128+
toggle component allows you to specify icons to display on the button for both "on" and "off" states:
129+
130+
```html
131+
<x-switch-toggle>
132+
<x-slot name="offIcon">
133+
<x-heroicon-s-x class="w-3 h-3 text-gray-400" />
134+
</x-slot>
135+
136+
<x-slot name="onIcon">
137+
<x-heroicon-s-check class="w-3 h-3 text-blue-600" />
138+
</x-slot>
139+
</x-switch-toggle>
140+
```
141+
142+
In this example, you will see an "x" icon when the switch is "off", and a checkmark icon when the switch is "on". **Note:** This example requires the
143+
[blade heroicon](https://github.com/blade-ui-kit/blade-heroicons) package.

0 commit comments

Comments
 (0)