Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(VNumberInput): ability to hide controls + spacing tweaks #19908

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

<v-number-input control-variant="split"></v-number-input>
</v-col>

<v-col cols="12" md="4" sm="4">
<h5>Hidden</h5>

<v-number-input control-variant="hidden"></v-number-input>
</v-col>
</v-row>
</v-container>
</template>
2 changes: 1 addition & 1 deletion packages/docs/src/pages/en/components/number-inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The `v-number-input` component has support for most of `v-field`'s props and is

#### Control-variant

The `control-variant` prop offers an easy way to customize steppers button layout. The following values are valid options: **default**, **stacked** and **split**.
The `control-variant` prop offers an easy way to customize steppers button layout. The following values are valid options: **default**, **stacked**, **split** and **hidden**.

<ExamplesExample file="v-number-input/prop-control-variant" />

Expand Down
14 changes: 12 additions & 2 deletions packages/vuetify/src/labs/VNumberInput/VNumberInput.sass
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@
-webkit-appearance: none

.v-field
padding-inline-end: 0
padding-inline-start: 0
&:not(:has(.v-field__prepend-inner > .v-icon))
padding-inline-start: 0

&:not(:has(.v-field__append-inner > .v-icon))
padding-inline-end: 0

.v-field__prepend-inner:has(.v-number-input__control) > .v-icon
margin-inline-end: 12px

.v-field__append-inner:has(.v-number-input__control) > .v-icon
margin-inline-start: 12px


&--inset
.v-divider
Expand Down
8 changes: 4 additions & 4 deletions packages/vuetify/src/labs/VNumberInput/VNumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type VNumberInputSlots = Omit<VTextFieldSlots, 'default'> & {
decrement: ControlSlot
}

type ControlVariant = 'default' | 'stacked' | 'split'
type ControlVariant = 'default' | 'stacked' | 'split' | 'hidden'

const makeVNumberInputProps = propsFactory({
controlVariant: {
Expand All @@ -55,7 +55,7 @@ const makeVNumberInputProps = propsFactory({
default: 1,
},

...omit(makeVTextFieldProps({}), ['appendInnerIcon', 'modelValue', 'prependInnerIcon']),
...omit(makeVTextFieldProps({}), ['modelValue']),
}, 'VNumberInput')

export const VNumberInput = genericComponent<VNumberInputSlots>()({
Expand Down Expand Up @@ -297,7 +297,7 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({

{ incrementControlNode() }
</div>
) : (props.reverse
) : (props.reverse || controlVariant.value === 'hidden'
? undefined
: <>{ dividerNode() }{ controlNode() }</>)

Expand All @@ -311,7 +311,7 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({

<VDivider vertical />
</div>
) : (props.reverse
) : (props.reverse && controlVariant.value !== 'hidden'
? <>{ controlNode() }{ dividerNode() }</>
: undefined)

Expand Down