Skip to content

Commit de6a46d

Browse files
andreyjamerSqrczcoderabbitai[bot]
authored
feat: FwbInput: Split input and block classes (#325)
* feat: FwbInput: Split input and block classes * Fixed grammar mistakes * Update FwbInputExampleBlockClasses.vue added class for dark theme * Update docs/components/input/examples/FwbInputExampleBlockClasses.vue Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Sqrcz <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 04bab19 commit de6a46d

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

docs/components/input.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import FwbInputExample from './input/examples/FwbInputExample.vue'
33
import FwbInputExampleSize from './input/examples/FwbInputExampleSize.vue'
44
import FwbInputExampleDisabled from './input/examples/FwbInputExampleDisabled.vue'
55
import FwbInputExampleHelper from './input/examples/FwbInputExampleHelper.vue'
6+
import FwbInputExampleBlockClasses from './input/examples/FwbInputExampleBlockClasses.vue'
67
import FwbInputExamplePrefix from './input/examples/FwbInputExamplePrefix.vue'
78
import FwbInputExampleSuffix from './input/examples/FwbInputExampleSuffix.vue'
89
import FwbInputExampleRequired from './input/examples/FwbInputExampleRequired.vue'
@@ -103,6 +104,33 @@ const name = ref('')
103104
</script>
104105
```
105106

107+
## Extra CSS classes
108+
109+
Sometimes it is required to add some customization to the input or the input wrapper.
110+
By default, `class` attribute is bound to the input element. To customize the input wrapper you can use the `block-classes` property.
111+
It accepts the values as the `class` attribute
112+
113+
<fwb-input-example-block-classes />
114+
```vue
115+
<template>
116+
<fwb-input
117+
v-model="name"
118+
label="First name"
119+
placeholder="enter your first name"
120+
required
121+
class="bg-green-200"
122+
block-classes="border-2 border-green-500 p-2 rounded-lg"
123+
/>
124+
</template>
125+
126+
<script setup>
127+
import { ref } from 'vue'
128+
import { FwbInput } from 'flowbite-vue'
129+
130+
const name = ref('')
131+
</script>
132+
```
133+
106134
## Slot - Helper
107135

108136
<fwb-input-example-helper />
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div class="vp-raw">
3+
<fwb-input
4+
v-model="name"
5+
label="First name"
6+
placeholder="enter your first name"
7+
class="bg-green-200 dark:bg-green-700"
8+
block-classes="border-2 border-green-500 p-2 rounded-lg"
9+
/>
10+
</div>
11+
</template>
12+
13+
<script lang="ts" setup>
14+
import { ref } from 'vue'
15+
import { FwbInput } from '../../../../src/index'
16+
17+
const name = ref('')
18+
</script>

src/components/FwbInput/FwbInput.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div>
2+
<div :class="blockClasses">
33
<label
44
v-if="label"
55
:class="labelClasses"
@@ -64,8 +64,13 @@ interface InputProps {
6464
type?: InputType
6565
autocomplete?: CommonAutoFill
6666
validationStatus?: ValidationStatus
67+
blockClasses?: string | string[] | Record<string, unknown>
6768
}
6869
70+
defineOptions({
71+
inheritAttrs: false,
72+
})
73+
6974
const props = withDefaults(defineProps<InputProps>(), {
7075
disabled: false,
7176
label: '',
@@ -75,6 +80,7 @@ const props = withDefaults(defineProps<InputProps>(), {
7580
type: 'text',
7681
autocomplete: 'off',
7782
validationStatus: undefined,
83+
blockClasses: undefined,
7884
})
7985
8086
const model = useVModel(props, 'modelValue')

0 commit comments

Comments
 (0)