|
1 | 1 | # Textual and Value inputs
|
2 | 2 |
|
3 |
| -> Create various text style inputs such as: `text`, `password`, `number`, `url`, |
4 |
| -`email`, `search`, `range` and more. |
| 3 | +> Create various type inputs such as: `text`, `password`, `number`, `url`, |
| 4 | +`email`, `search`, `range`, `date` and more. |
5 | 5 |
|
6 | 6 | ```html
|
7 | 7 | <template>
|
@@ -65,16 +65,81 @@ will be rendered and a console warning will be issued.
|
65 | 65 | **Caveats with input types:**
|
66 | 66 | - Not all browsers support all input types, nor do some types render in the same format across
|
67 | 67 | browser types/versions.
|
68 |
| -- Browsers that do not support a particular type will fall back to |
69 |
| -a `text` input type (event thoough the rendered `type` attribute markup shows the requested type). |
| 68 | +- Browsers that do not support a particular type will fall back to a `text` input type (event thoough the rendered `type` attribute markup shows the requested type). |
| 69 | +- No testing is performed to see if the requested input type is supported by the browser. |
70 | 70 | - Chrome lost support for `datetime` in version 26, Opera in version 15, and Safari in iOS 7.
|
71 | 71 | Instead of using `datetime`, since support should be deprecated, use `date` and `time`
|
72 | 72 | as two separate inputs.
|
| 73 | +- `date` and `time` inputs are native borwser types, and are not a custom date/time picker. |
73 | 74 | - For date and time style inputs, where supported, the displayed value in the GUI may be different
|
74 |
| -than what is returned by it's value. |
| 75 | +than what is returned by it's value (i.e. ordering of year-month-date). |
75 | 76 | - Regardless of input type, the value is **always** returned as a string representation.
|
76 | 77 | - `v-model.lazy` is not supported by `<b-form-input>` (nor any custom vue component).
|
77 | 78 | - `v-model` modifiers `.number` and `.trim` can cause unexpected cursor jumps when the user is typing (this is a Vue issue with `v-model` on custom components). Avoid using these modifiers.
|
| 79 | +- Older version of firefox may not support `readonly` for `range` type inputs. |
| 80 | +- Input types that do not support `min`, `max` and `step` (i.e. `text`, `password`, `tel`, `email`, `url`, etc) will silently ignore these values (although they will still be rendered on the input markup). |
| 81 | + |
| 82 | +### Range type input |
| 83 | +Inputs with type `range` render using Bootstrap V4's `.custom-range` class. The track |
| 84 | +(the background) and thumb (the value) are both styled to appear the same across browsers. |
| 85 | + |
| 86 | +Range inputs have implicit values for `min` and `max` of `0` and `100` respectively. You |
| 87 | +may specify new values for those using the `min` and `max` props. |
| 88 | + |
| 89 | +```html |
| 90 | +<template> |
| 91 | + <div> |
| 92 | + <label for="range-1">Example range with min and max</label> |
| 93 | + <b-form-input type="range" id="range-1" v-model="value" min="0" max="5" /> |
| 94 | + <p class="mt-2">Value: {{ value }}</p> |
| 95 | + </div> |
| 96 | +</template> |
| 97 | + |
| 98 | +<script> |
| 99 | +export default { |
| 100 | + data () { |
| 101 | + return { |
| 102 | + value: 2 |
| 103 | + } |
| 104 | + } |
| 105 | +} |
| 106 | +</script> |
| 107 | + |
| 108 | +<!-- form-input-range-1.vue --> |
| 109 | +``` |
| 110 | + |
| 111 | +By default, range inputs “snap” to integer values. To change this, you can specify a `step` |
| 112 | +value. In the example below, we double the number of steps by using step="0.5". |
| 113 | + |
| 114 | +```html |
| 115 | +<template> |
| 116 | + <div> |
| 117 | + <label for="range-2">Example range with step value</label> |
| 118 | + <b-form-input type="range" id="range-2" v-model="value" min="0" max="5" step="0.5" /> |
| 119 | + <p class="mt-2">Value: {{ value }}</p> |
| 120 | + </div> |
| 121 | +</template> |
| 122 | + |
| 123 | +<script> |
| 124 | +export default { |
| 125 | + data () { |
| 126 | + return { |
| 127 | + value: 2 |
| 128 | + } |
| 129 | + } |
| 130 | +} |
| 131 | +</script> |
| 132 | + |
| 133 | +<!-- form-input-range-2.vue --> |
| 134 | +``` |
| 135 | + |
| 136 | +**Note:** Range inputs (as do all input types) return their value as a string. You may |
| 137 | +need to convert the value to a native number by using `Number(value)`, `parseInt(value, 10)`, |
| 138 | +`parseFloat(value)`, or use the `.number` modifier on the `v-model`. |
| 139 | + |
| 140 | +**Note:** Bootsttrap V4.1 CSS does not include styling for range inputs inside input groups, |
| 141 | +nor validation styling on range inputs. However, Bootstrap-Vue includes custom styling to handle |
| 142 | +these situations until styling is included in Bootstrap V4. |
78 | 143 |
|
79 | 144 |
|
80 | 145 | ## Control sizing
|
@@ -107,6 +172,14 @@ To control width, place the input inside standard Bootstrap grid column.
|
107 | 172 | <!-- form-input-size-1.vue -->
|
108 | 173 | ```
|
109 | 174 |
|
| 175 | +**Note:** Input type `range` currently does not support control sizing unless it is placed inside a |
| 176 | +`<b-input-group>` which has its `size` prop set. |
| 177 | + |
| 178 | +**Note:** The native HTML `<input>` attribute `size` (which sets a horizontal width on the |
| 179 | +`<input>` in characters) is not supported. Use styling, utility classes, or the layout rows (`<b-row>`) |
| 180 | +and columns (`<b-col>`) to set the desired width. |
| 181 | + |
| 182 | + |
110 | 183 | ## Contextual States
|
111 | 184 | Bootstrap includes validation styles for `valid` and `invalid` states
|
112 | 185 | on most form controls.
|
@@ -299,6 +372,7 @@ If you want to have `<b-form-input readonly>` elements in your form styled as pl
|
299 | 372 | text, set the `plaintext` prop (no need to set `readonly`) to remove the default form
|
300 | 373 | field styling and preserve the correct margin and padding.
|
301 | 374 |
|
| 375 | +The `plaintext` option is not supported by input types `color` or `range`. |
302 | 376 |
|
303 | 377 | ## Disabling mousewheel events on numeric-like inputs
|
304 | 378 | On some browsers, scrolling the mousewheel while a numeric-like input is focused will
|
|
0 commit comments