3
3
> Create various text style inputs such as: ` text ` , ` password ` , ` number ` , ` url ` ,
4
4
` search ` , and more. Also supports creating ` textarea ` controls.
5
5
6
+ ** Example:**
6
7
``` html
7
8
<template >
8
9
<div >
9
- <b-form-input v-model =" text"
10
+ <h5 >Text input with formatter</h5 >
11
+ <b-form-input v-model =" text1"
10
12
type =" text"
11
13
placeholder =" Enter your name"
12
- :state =" text.length?'success':'warning'"
13
14
:formatter =" format"
14
15
></b-form-input >
15
16
<small class =" text-muted" >We will convert your name to lowercase instantly</small >
17
+ <p >Value: {{ text1 }}</p >
16
18
17
- <br >
18
- <br >
19
-
20
- <b-form-input v-model =" text"
19
+ <h5 >Text input with lazy formatter (on bluer)</h5 >
20
+ <b-form-input v-model =" text2"
21
21
type =" text"
22
22
placeholder =" Enter your name"
23
- :state =" text.length?'success':'warning'"
24
23
:formatter =" format"
25
24
lazy-formatter
26
25
></b-form-input >
27
26
<small class =" text-muted" >This one is a little lazy!</small >
27
+ <p >Value: {{ text2 }}</p >
28
28
29
- <br >
30
- <br >
31
-
32
- <b-form-input textarea v-model =" text" placeholder =" Text area mode" ></b-form-input >
33
-
34
- <br >
35
- <p >Value: {{text}}</p >
29
+ <h5 >Textarea with auto row height</h5 >
30
+ <b-form-input textarea v-model =" text3" placeholder =" Text area mode" ></b-form-input >
31
+ <p >Value: </p >
32
+ <pre >{{ text3 }}</pre >
36
33
</div >
37
34
</template >
38
35
39
36
<script >
40
37
export default {
41
38
data: {
42
- text: ' ' ,
39
+ text1: ' ' ,
40
+ text2: ' ' ,
41
+ text3: ' '
43
42
},
44
43
methods: {
45
44
format (value ) {
@@ -49,48 +48,58 @@ export default {
49
48
}
50
49
</script >
51
50
52
- <!-- form-input.vue -->
51
+ <!-- form-input-1 .vue -->
53
52
```
54
53
54
+ ### Input type
55
+ ` <b-form-input> ` defaults to a ` text ` input, but you can set it to any other text-like
56
+ type, such as ` password ` , ` number ` , ` url ` , etc, by setting the ` type ` prop.
57
+
58
+ #### Textarea mode
59
+ Render a ` <textarea> ` element by setting the ` textarea ` prop to ` true ` . The
60
+ ` type ` prop is ignored when prop ` textarea ` is set.
61
+
62
+ By default the ` <textarea> ` will automatically size its height based on on the number
63
+ lines (separated by newlines) of text it contains. You can override this behaviour by supplying
64
+ a numeric value to the ` rows ` prop. The ` rows ` prop has no effect on other input types.
65
+
66
+
55
67
### Formatter
56
- ` <b-form-input> ` supports optional formatting by passing a function reference to the ` formatter ` prop.
68
+ ` <b-form-input> ` optionally supports formatting by passing a function reference to the ` formatter ` prop.
57
69
58
- By default, formatting occurs when the control's input event fires. You can use the boolean
70
+ By default, formatting occurs when the control's native ` input ` event fires. You can use the boolean
59
71
prop ` lazy-formatter ` to restrict the formatter function to being called on the
60
- control's ` change ` event only .
72
+ control's native ` change ` event (which usually occurs on blur) .
61
73
62
74
The ` formatter ` function receives a single argument which is the control's current value, and
63
75
should return the formatted value.
64
76
65
- ### Textarea
66
- Render a ` <textarea> ` element by setting the ` textarea ` prop to ` true ` . The
67
- ` type ` prop is ignored when prop ` textarea ` is set.
77
+ No formatting occurs if a ` formatter ` is not provided.
68
78
69
- By default the ` <textarea> ` will automatically size its height based on on the number
70
- lines (separated by newlines) of text it contains. You can override this behaviour by supplying
71
- a numeric value to the ` rows ` prop. The ` rows ` prop has no effect on other input types.
72
79
73
80
### Static Control
74
81
Easily convert a ` <b-form-input> ` control to a Bootstrap static form
75
82
control by setting the prop ` static ` to true.
76
83
77
84
You can also use the ` <b-form-input-static> ` component to create static form controls.
78
85
86
+
79
87
### Control sizing
80
88
Set heights using the ` size ` prop to ` sm ` or ` lg ` for small or large respectively.
81
89
82
90
To control width, place the input inside standard Bootstrap grid column.
83
91
92
+
84
93
### Contextual States
85
94
Bootstrap includes validation styles for danger, warning, and success states
86
- on most form controls. Note that these states will not appear unless the
87
- ` <b-form-input> ` is wrapped in a ` <b-form fieldset> ` which also has the same
88
- ` state ` value.
95
+ on most form controls.
89
96
90
- On ` <b-form-input> ` , these states will add the corresponding validtion state
91
- icon at the right of the input. Validation icons are url()s configured via
92
- Bootstrap V4's Sass variables that are applied to background-image declarations
93
- for each state.
97
+ ** Note that these states will not appear unless the ` <b-form-input> ` is
98
+ wrapped in a ` <b-form fieldset> ` which also has the same ` state ` value.**
99
+
100
+ On ` <b-form-input> ` , these states will add the corresponding ** validtion state icon**
101
+ at the right of the input. Validation icons are url()s configured via Bootstrap V4's
102
+ SaSS variables that are applied to background-image declarations for each state.
94
103
95
104
Generally speaking, you’ll want to use a particular state for specific types of feedback:
96
105
- ` danger ` is great for when there’s a blocking or required field. A user must fill in
@@ -100,10 +109,10 @@ soft validation before a user attempts to submit a form.
100
109
- ` success ` is ideal for situations when you have per-field validation throughout a form
101
110
and want to encourage a user through the rest of the fields.
102
111
103
- To apply one of the contextual states on ` <b-form-input> ` , set the ` state ` prop
112
+ To apply one of the contextual state icons on ` <b-form-input> ` , set the ` state ` prop
104
113
to ` danger ` , ` warning ` , or ` success ` . Remember that you will not see the validation
105
114
state icon unless the input is wrapped in a ` <b-form-fieldset> ` which also
106
- has the same ` state ` applied!
115
+ has the ** same** ` state ` applied!
107
116
108
117
#### Conveying contextual validation state to assistive technologies and colorblind users:
109
118
Using these contextual states to denote the state of a form control only provides
@@ -115,6 +124,7 @@ could include a hint about state in the form control's `<label>` text itself, or
115
124
providing an additional help text block. Specifically for assistive technologies,
116
125
invalid form controls can also be assigned an ` aria-invalid="true" ` attribute.
117
126
127
+
118
128
### ARIA ` aria-invalid ` attribute
119
129
When ` <form-input> ` has an invalid contextual state (i.e. ` danger ` ) you may also
120
130
want to set the ` <b-form-input> ` prop ` invalid ` to ` true ` , or a string value.
0 commit comments