2020-05-22 16:27:48 -04:00
|
|
|
# Input
|
|
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
[component-header:sl-input]
|
|
|
|
|
|
2020-07-08 16:42:53 -04:00
|
|
|
Inputs collect data from the user.
|
2020-05-31 09:59:23 -04:00
|
|
|
|
2020-05-22 16:27:48 -04:00
|
|
|
```html preview
|
2020-07-12 09:42:25 -04:00
|
|
|
<sl-input type="text"></sl-input>
|
2020-05-31 09:59:23 -04:00
|
|
|
```
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-07-12 07:42:22 -04:00
|
|
|
?> This component doesn't work with standard forms. Use [`<sl-form>`](/components/form.md) instead.
|
|
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
## Examples
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-07-02 07:51:54 -04:00
|
|
|
### Labels
|
|
|
|
|
|
2020-07-12 09:42:25 -04:00
|
|
|
Use the `label` attribute to give the input an accessible label.
|
|
|
|
|
|
2020-07-02 07:51:54 -04:00
|
|
|
```html preview
|
|
|
|
|
<sl-input type="text" label="Name"></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-07-02 07:51:54 -04:00
|
|
|
<sl-input type="email" label="Email" placeholder="bob@example.com"></sl-input>
|
|
|
|
|
```
|
|
|
|
|
|
2020-07-12 09:42:25 -04:00
|
|
|
### Placeholder
|
|
|
|
|
|
|
|
|
|
Use the `placeholder` attribute to add a placeholder.
|
|
|
|
|
|
|
|
|
|
```html preview
|
|
|
|
|
<sl-input type="text" placeholder="Type something"></sl-input>
|
|
|
|
|
```
|
|
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
### Size
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-07-12 09:42:25 -04:00
|
|
|
Use the `size` attribute to change an input's size.
|
|
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
```html preview
|
2020-07-03 08:35:08 -04:00
|
|
|
<sl-input placeholder="Small" size="small"></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-07-03 08:35:08 -04:00
|
|
|
<sl-input placeholder="Medium" size="medium"></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-07-03 08:35:08 -04:00
|
|
|
<sl-input placeholder="Large" size="large"></sl-input>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Pill
|
|
|
|
|
|
2020-07-12 09:42:25 -04:00
|
|
|
Use the `pill` prop to give inputs rounded edges.
|
|
|
|
|
|
2020-07-03 08:35:08 -04:00
|
|
|
```html preview
|
|
|
|
|
<sl-input placeholder="Small" size="small" pill></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-07-03 08:35:08 -04:00
|
|
|
<sl-input placeholder="Medium" size="medium" pill></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-07-03 08:35:08 -04:00
|
|
|
<sl-input placeholder="Large" size="large" pill></sl-input>
|
2020-05-31 09:59:23 -04:00
|
|
|
```
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
### Prefix & Suffix Icons
|
2020-07-06 08:36:48 -04:00
|
|
|
|
2020-07-12 09:42:25 -04:00
|
|
|
Use the `prefix` and `suffix` slots to add icons.
|
|
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
```html preview
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="text" placeholder="Small" size="small">
|
|
|
|
|
<sl-icon name="tag" slot="prefix"></sl-icon>
|
2020-06-08 10:26:26 -04:00
|
|
|
<sl-icon name="gear" slot="suffix"></sl-icon>
|
2020-05-22 16:27:48 -04:00
|
|
|
</sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="text" placeholder="Medium" size="medium">
|
|
|
|
|
<sl-icon name="tag" slot="prefix"></sl-icon>
|
2020-06-08 10:26:26 -04:00
|
|
|
<sl-icon name="gear" slot="suffix"></sl-icon>
|
2020-05-22 16:27:48 -04:00
|
|
|
</sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="text" placeholder="Large" size="large">
|
|
|
|
|
<sl-icon name="tag" slot="prefix"></sl-icon>
|
2020-06-08 10:26:26 -04:00
|
|
|
<sl-icon name="gear" slot="suffix"></sl-icon>
|
2020-05-22 16:27:48 -04:00
|
|
|
</sl-input>
|
2020-05-31 09:59:23 -04:00
|
|
|
```
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
### Clearable
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-07-12 09:42:25 -04:00
|
|
|
Add the `clearable` prop to add a clear button when the input has content.
|
|
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
```html preview
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="text" placeholder="Clearable" size="small" clearable></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="text" placeholder="Clearable" size="medium" clearable></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="text" placeholder="Clearable" size="large" clearable></sl-input>
|
2020-05-31 09:59:23 -04:00
|
|
|
```
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
### Toggle Password
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-07-12 09:42:25 -04:00
|
|
|
Add the `toggle-password` prop to add a toggle button that will show the password when activated.
|
|
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
```html preview
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="password" placeholder="Password Toggle" size="small" toggle-password></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="password" placeholder="Password Toggle" size="medium" toggle-password></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="password" placeholder="Password Toggle" size="large" toggle-password></sl-input>
|
2020-05-31 09:59:23 -04:00
|
|
|
```
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
### Disabled
|
2020-05-22 16:27:48 -04:00
|
|
|
|
2020-07-12 09:42:25 -04:00
|
|
|
Use the `disabled` attribute to disable an input.
|
|
|
|
|
|
2020-05-31 09:59:23 -04:00
|
|
|
```html preview
|
|
|
|
|
<sl-input type="text" placeholder="Disabled" size="small" disabled></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="text" placeholder="Disabled" size="medium" disabled></sl-input>
|
2020-07-08 16:44:08 -04:00
|
|
|
<br>
|
2020-05-22 16:27:48 -04:00
|
|
|
<sl-input type="text" placeholder="Disabled" size="large" disabled></sl-input>
|
|
|
|
|
```
|
2020-07-02 08:16:06 -04:00
|
|
|
|
|
|
|
|
[component-metadata:sl-input]
|