Skip to content

Commit

Permalink
feat(textfield): add no-spinner to remove number spin buttons
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 595788647
  • Loading branch information
asyncLiz authored and copybara-github committed Jan 4, 2024
1 parent 553aaa6 commit 3c6e550
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions textfield/internal/_input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@
}
}

// Optionally remove number input's spinner
.no-spinner .input {
&::-webkit-inner-spin-button,
&::-webkit-outer-spin-button {
display: none;
}

&[type='number'] {
-moz-appearance: textfield;
}
}

:focus-within .input {
caret-color: var(--_focus-caret-color);
}
Expand Down
6 changes: 6 additions & 0 deletions textfield/internal/text-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ export abstract class TextField extends textFieldBaseClass {
*/
@property({type: Number}) minLength = -1;

/**
* When true, hide the spinner for `type="number"` text fields.
*/
@property({type: Boolean, attribute: 'no-spinner'}) noSpinner = false;

/**
* A regular expression that the text field's value must match to pass
* constraint validation.
Expand Down Expand Up @@ -514,6 +519,7 @@ export abstract class TextField extends textFieldBaseClass {
'disabled': this.disabled,
'error': !this.disabled && this.hasError,
'textarea': this.type === 'textarea',
'no-spinner': this.noSpinner,
};

return html`
Expand Down

0 comments on commit 3c6e550

Please sign in to comment.