Skip to content

Commit c43c76b

Browse files
committed
feat(CFormControlWrapper): allow passing class names to the CFormFloaging component
1 parent 9f310bb commit c43c76b

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

packages/coreui-vue/src/components/form/CFormControlWrapper.ts

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { CFormText } from './CFormText'
77
import type { ComponentProps } from '../../utils/ComponentProps'
88

99
interface CFormControlWrapperProps extends ComponentProps<typeof CFormControlValidation> {
10+
floatingClassName?: string
1011
floatingLabel?: string
1112
id?: string
1213
label?: string
@@ -18,6 +19,12 @@ const CFormControlWrapper = defineComponent({
1819
inheritAttrs: false,
1920
props: {
2021
...CFormControlValidation.props,
22+
/**
23+
* A string of all className you want applied to the floating label wrapper.
24+
*
25+
* @since 5.5.0
26+
*/
27+
floatingClassName: String,
2128
/**
2229
* Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
2330
*
@@ -69,29 +76,36 @@ const CFormControlWrapper = defineComponent({
6976

7077
return () =>
7178
props.floatingLabel
72-
? h(CFormFloating, () => [
73-
slots.default && slots.default(),
74-
h(
75-
CFormLabel,
76-
{
77-
for: props.id,
78-
},
79-
{
80-
default: () => (slots.label && slots.label()) || props.label || props.floatingLabel,
81-
},
82-
),
83-
(props.text || slots.text) &&
79+
? h(
80+
CFormFloating,
81+
{
82+
class: props.floatingClassName,
83+
},
84+
() => [
85+
slots.default && slots.default(),
8486
h(
85-
CFormText,
87+
CFormLabel,
8688
{
87-
id: props.describedby,
89+
for: props.id,
8890
},
8991
{
90-
default: () => (slots.text && slots.text()) || props.text,
92+
default: () =>
93+
(slots.label && slots.label()) || props.label || props.floatingLabel,
9194
},
9295
),
93-
formControlValidation(),
94-
])
96+
(props.text || slots.text) &&
97+
h(
98+
CFormText,
99+
{
100+
id: props.describedby,
101+
},
102+
{
103+
default: () => (slots.text && slots.text()) || props.text,
104+
},
105+
),
106+
formControlValidation(),
107+
],
108+
)
95109
: [
96110
(props.label || slots.label) &&
97111
h(

0 commit comments

Comments
 (0)