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

Commit 022de4d

Browse files
authored
V8 docs (#83)
1 parent 89e28ea commit 022de4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3273
-837
lines changed

CHANGELOG.md

Lines changed: 164 additions & 164 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,24 @@ composer require rawilk/laravel-form-components
1919
```
2020

2121
You can publish the config file with:
22+
2223
```bash
23-
php artisan fc:publish
24+
php artisan vendor:publish --tag="form-components-config"
2425
```
2526

26-
**Tip:** You can also publish the package views by adding the `--views` flag to the command:
27+
You can view the default configuration here: https://github.com/rawilk/laravel-form-components/blob/main/config/form-components.php
28+
29+
You can publish the package's views with this command:
2730

2831
```bash
29-
php artisan fc:publish --views
32+
php artisan vendor:publish --tag="form-components-views"
3033
```
3134

32-
You can view the default configuration here: https://github.com/rawilk/laravel-form-components/blob/main/config/form-components.php
35+
If you want to override the package's language lines, you can publish them with this command:
36+
37+
```bash
38+
php artisan vendor:publish --tag="form-components-translations"
39+
```
3340

3441
## Documentation
3542

@@ -41,7 +48,7 @@ For a demo of some of the components, please visit: https://laravel-form-compone
4148

4249
## Testing
4350

44-
``` bash
51+
```bash
4552
composer test
4653
```
4754

@@ -59,22 +66,23 @@ Please review [my security policy](../../security) on how to report security vul
5966

6067
## Credits
6168

62-
- [Randall Wilk](https://github.com/rawilk)
63-
- [All Contributors](../../contributors)
69+
- [Randall Wilk](https://github.com/rawilk)
70+
- [All Contributors](../../contributors)
6471

6572
This package is also heavily inspired by [Laravel Form Components](https://github.com/protonemedia/laravel-form-components) and [Blade UI Kit](https://blade-ui-kit.com/).
73+
A lot of inspiration for some JS components is taken from [Alpine Headless Components](https://alpinejs.dev/components#headless).
6674

6775
## Alternatives
6876

6977
This package was created to satisfy my own needs and preferences, and relies on TailwindCSS, TailwindUI, and AlpineJS for styling and functionality. You can always
7078
try one of these alternatives if your needs differ:
7179

72-
- [Blade UI Kit](https://blade-ui-kit.com/)
73-
- [Laravel Form Components](https://github.com/protonemedia/laravel-form-components)
80+
- [Blade UI Kit](https://blade-ui-kit.com/)
81+
- [Laravel Form Components](https://github.com/protonemedia/laravel-form-components)
7482

7583
## Disclaimer
7684

77-
This package is not affiliated with, maintained, authorized, endorsed or sponsored by Laravel, TailwindCSS, Laravel Livewire, or any of its affiliates.
85+
This package is not affiliated with, maintained, authorized, endorsed or sponsored by Laravel, TailwindCSS, Laravel Livewire, Alpine.js, or any of its affiliates.
7886

7987
## License
8088

config/form-components.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
// Defaults for the date picker component.
110110
'date_picker' => [
111111
// Allow date picker to open from clicking on the input by default.
112-
'click_opens' => true,
112+
'click_opens' => false,
113113

114114
// Allow user to modify the text of the input by default.
115115
'allow_input' => true,

docs/_index.md

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

docs/advanced-usage/addons.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
---
2+
title: Addons
3+
sort: 1
4+
---
5+
6+
## Introduction
7+
8+
Addons provide a way to prepend or append text or an icon to an input. Both leading and trailing addons can be added to the input either by use of props or slots.
9+
When rendering the input, only one type of leading and one type of trailing addon will be rendered at a time.
10+
11+
In the examples shown on this page, we will be using the `input` component, however addons will work with most other components as well.
12+
13+
## Leading Addons
14+
15+
There are three types of "leading" addons offered by this package: leading addon, inline addon, and leading icon. Each of these will be rendered somewhere
16+
on the left side of an input element.
17+
18+
### Leading Addon
19+
20+
A leading addon will be rendered as text on top of a light gray background at the beginning of the input. To render a leading
21+
addon, specify the text either in the `leading-addon` attribute or the `leadingAddon` slot.
22+
23+
Via prop:
24+
25+
```html
26+
<x-input name="url" leading-addon="https://" />
27+
```
28+
29+
Via slot:
30+
31+
```html
32+
<x-input name="url">
33+
<x-slot:leading-addon>https://</x-slot:leading-addon>
34+
</x-input>
35+
```
36+
37+
### Inline Addon
38+
39+
Inline addon is similar to leading addon, however there is no background behind the text. You are also responsible
40+
for setting the left padding of the input to allow for enough room for your text to fit at the beginning of the
41+
input.
42+
43+
You can set the inline addon by using the `inline-addon` attribute or the `inlineAddon` slot.
44+
45+
Via prop:
46+
47+
```html
48+
<x-input name="url" inline-addon="https://" />
49+
```
50+
51+
Via slot:
52+
53+
```html
54+
<x-input name="url">
55+
<x-slot:inline-addon>https://</x-slot:inline-addon>
56+
</x-input>
57+
```
58+
59+
To modify the padding, you should use a custom class on the input. Since this padding value is controlled via a [variable](/docs/laravel-form-components/{version}/advanced-usage/customizing-css#user-content-variables),
60+
you could just use an [arbitrary value](https://tailwindcss.com/docs/adding-custom-styles#using-arbitrary-values) in a custom class name:
61+
62+
```html
63+
<x-input
64+
name="url"
65+
inline-addon="https://"
66+
class="![--inline-addon-pl:theme(spacing.4)]"
67+
/>
68+
```
69+
70+
This is the equivalent of `pl-4` on the input. However, it's recommended to override the variable value instead. If you do it this way, you need to be sure to make the rule
71+
`!important` (prefix the class name with `!`) so it actually overrides the variable value.
72+
73+
### Leading Icon
74+
75+
Instead of text, you can prepend an icon to the input instead. The package is styled for
76+
[blade heroicon svgs](https://github.com/blade-ui-kit/blade-heroicons), but you are free
77+
to use whatever icons you want to.
78+
79+
To prepend an icon, you can use the `leading-icon` prop, or the `leadingIcon` slot:
80+
81+
Via prop:
82+
83+
```html
84+
<x-input name="url" leading-icon="heroicon-m-at-symbol" />
85+
```
86+
87+
Via slot:
88+
89+
```html
90+
<x-input name="url">
91+
<x-slot:leading-icon>
92+
<x-heroicon-m-at-symbol />
93+
</x-slot:leading-icon>
94+
</x-input>
95+
```
96+
97+
If you pass the icon name via prop, the component will use the `<x-dynamic-component />` component behind-the-scenes to render the component for convenience.
98+
99+
## Trailing Addons
100+
101+
There are three types of "trailing" addons offered by this package: trailing addon, trailing inline addon, and trailing icon. These all behave like the leading addon version of them, except now they
102+
will be on the right side of the input element.
103+
104+
### Trailing Addon
105+
106+
Like the leading addon, the trailing addon will render text inside a light gray background at the end of the input this time. To render a trailing addon,
107+
specify text in either the `trailing-addon` prop or the `trailingAddon` slot.
108+
109+
Via prop:
110+
111+
```html
112+
<x-input name="url" trailing-addon="lbs" />
113+
```
114+
115+
Via slot:
116+
117+
```html
118+
<x-input name="url">
119+
<x-slot:trailing-addon>lbs</x-slot:trailing-addon>
120+
</x-input>
121+
```
122+
123+
### Trailing Inline Addon
124+
125+
Like the inline addon, the trailing inline addon will add text directly inside the input, but this time on the right
126+
side of the input. Also like the inline addon, you may need to specify a custom padding amount for the input.
127+
128+
You can add a trailing inline addon by using either the `trailing-inline-addon` attribute or the `trailingInlineAddon` slot.
129+
130+
Via prop:
131+
132+
```html
133+
<x-input name="amount" trailing-inline-addon="USD" />
134+
```
135+
136+
Via slot:
137+
138+
```html
139+
<x-input name="amount">
140+
<x-slot:trailing-inline-addon>USD</x-slot:trailing-inline-addon>
141+
</x-input>
142+
```
143+
144+
To adjust the amount of padding on the right side on the input, you should override the `--inline-addon-pr` CSS variable. See [Inline Addon](#user-content-inline-addon)
145+
for an example on how to this.
146+
147+
### Trailing Icon
148+
149+
You can append an icon to an input similar to prepending one. You can do so using either the `trailing-icon` prop or the `trailingIcon` slot:
150+
151+
Via prop:
152+
153+
```html
154+
<x-input name="url" trailing-icon="heroicon-m-magnifying-glass" />
155+
```
156+
157+
Via slot:
158+
159+
```html
160+
<x-input name="url">
161+
<x-slot:trailing-icon>
162+
<x-heroicon-m-magnifying-glass />
163+
</x-slot:trailing-icon>
164+
</x-input>
165+
```
166+
167+
If you pass the icon name via prop, the component will use the `<x-dynamic-component />` component behind-the-scenes to render the component for convenience.
168+
169+
## Before Slot
170+
171+
The `before` slot allows you the flexibility to render any kind of HTML you need to directly before the input element. If you have a leading addon on the input, it will render before that markup.
172+
173+
```html
174+
<x-input>
175+
<x-slot:before>
176+
<div>Before slot content</div>
177+
</x-slot:before>
178+
</x-input>
179+
```
180+
181+
## After Slot
182+
183+
The `after` slot allows you the flexibility to render any kind of HTML you need to directly after the input element. If you have a trailing addon on the input, it will render after that markup.
184+
185+
```html
186+
<x-input>
187+
<x-slot:after>
188+
<div>After slot content</div>
189+
</x-slot:after>
190+
</x-input>
191+
```
192+
193+
## Addon Slot Attributes
194+
195+
All types of leading and trailing addons (except the before and after slots) are able to render custom HTML attributes onto the addon markup for you. The only
196+
requirement is that you use the named slot for the addon, and not the prop.
197+
198+
The following example will add an id and an attribute called data-foo onto the leading addon markup for the input.
199+
200+
```html
201+
<x-input>
202+
<x-slot:leading-addon id="hello-world" data-foo="bar">
203+
Hello world
204+
</x-slot:leading-addon>
205+
</x-input>
206+
```
207+
208+
Those attributes will be rendered onto the `<span>` that wraps `Hello world` and **not** onto the input itself.

0 commit comments

Comments
 (0)