Number input

Number input is a form element that allows the user to enter a number. It provides a way to increase or decrease the value by using the plus and minus buttons.

Design system docs Examples Default number input
<dap-ds-number-input label="Number of children"></dap-ds-number-input>
Statuses
<dap-ds-stack direction="column">
  <dap-ds-number-input label="Disabled" disabled></dap-ds-number-input>
  <dap-ds-number-input label="Read only" value="8888" readonly></dap-ds-number-input>
  <dap-ds-number-input label="Success" status="success"></dap-ds-number-input>
  <dap-ds-number-input label="Error" status="error" label="Number" required feedback="wrong number" feedbackType="negative"></dap-ds-number-input>
</dap-ds-stack>
Sizes
<dap-ds-stack direction="column">
  <dap-ds-number-input
    label="XSmall"
    description="This is an extra small number input"
    size="xs"
    feedback="This is a feedback message"
    feedbacktype="negative"
  >
  </dap-ds-number-input>
  <dap-ds-number-input
    label="Small"
    description="This is a small number input"
    size="sm"
    feedback="This is a feedback message"
    feedbacktype="negative"
  >
  </dap-ds-number-input>
  <dap-ds-number-input
    label="Large"
    description="This is a large number input"
    size="lg"
    feedback="This is a feedback message"
    feedbacktype="negative"
  >
  </dap-ds-number-input>
</dap-ds-stack>
Thousand separator

Thousand separator is the character that separates the thousands in the number. Every country has a different thousand separator. In Hungary we use dot . as a thousand separator. This is very important to accessibility to set the correct thousand separator, because the screen reader will recognize the language of the current page and read the number with the correct thousand separator. Read more about digit grouping.

Do not use space as a thousand separator, because it is not accessible for screen readers.

<dap-ds-number-input
  label="Thousand separator"
  value="1234567"
  thousandSeparator=".">
</dap-ds-number-input>
Decimal separator

Decimal separator is the character that separates the integer part of the number from the decimal part. Every country has a different decimal separator. In Hungary we use comma as a decimal separator. This is very important to accessibility to set the correct decimal separator, because the screen reader will recognize the language of the current page and read the number with the correct decimal separator. Read more about decimal separators.

<dap-ds-number-input
  label="Decimal separator"
  value="12345678,123"
  decimalSeparator=","
  thousandSeparator="."
></dap-ds-number-input>
Decimal scale

Decimal scale is the number of decimal places that the input will show.

<dap-ds-number-input
  label="Decimal scale"
  value="12345678,123334"
  decimalSeparator=","
  decimalScale="2">
</dap-ds-number-input>
Disable negative

Disable negative is the state of the input that disables the user from entering negative numbers.

<dap-ds-number-input
  label="Disable negative"
  value="-12345678,777"
  allowNegative="false"
  decimalScale="2"
></dap-ds-number-input>
Disable decimal

Disable decimal is the state of the input that disables the user from entering decimal numbers.

<dap-ds-number-input
  label="Disable decimal"
  value="12345678,345"
  allowDecimal="false"
></dap-ds-number-input>
Hide controls

Hide controls is the state of the input that hides the increment and decrement buttons.

<dap-ds-number-input label="Hide controls" hideControls></dap-ds-number-input>
Custom Styling

The number input component supports extensive customization beyond the default styles. This section demonstrates practical styling techniques and advanced customization patterns.

Quick Customization with CSS Custom Properties

For simple customizations, use CSS custom properties directly on the component:

<dap-ds-number-input
label="Custom Styled Number Input"
value="12345"
thousandSeparator="."
style={{
  '--dds-input-background': 'var(--dds-brand-100)',
  '--dds-input-border': '2px solid var(--dds-brand-600)',
  '--dds-input-text-color': 'var(--dds-brand-900)',
  '--dds-input-border-radius': 'var(--dds-radius-large)',
}}>
</dap-ds-number-input>
Advanced Styling with CSS Parts

Experiment with custom number input styling using CSS parts and custom properties. The number input component exposes several CSS parts for advanced styling: base, input, label, description, feedback, postfix, increment-button, decrement-button, increment-button-base, decrement-button-base, and more. Try the presets below or create your own styles:

Rounded StyleGradient ButtonsElevated ShadowBorder AccentMinimal DesignColorful HoverLarge ButtonsIcon StylingNeon Glow
☀️ Light🌙 Dark
CopyFormatReset
CSS Editor
Live Preview
Importing
import { DapDSNumberInput } from 'dap-design-system'
Importing React
import { DapDSNumberInputReact } from 'dap-design-system/react'
Tree-Shakeable Imports

For optimal bundle sizes, use the tree-shakeable import syntax:

import { DapDSNumberInput } from 'dap-design-system/components'
Attributes
PropertyTypeDefaultDescription
thousandSeparatorstring''The thousand separator of the input.
decimalSeparatorstring','The decimal separator of the input.
decimalScalenumberThe decimal scale of the input.
allowNegativestring'true'The allow negative state of the input.
allowDecimalstring'true'The allow decimal state of the input.
hideControlsbooleanfalseHides the increment and decrement buttons.
manualValueSetbooleantrue
labelstringThe label of the input.
placeholderstringThe placeholder of the input.
descriptionstringThe description of the input.
tooltipstringThe tooltip of the input.
tooltipPlacement'top', 'right' , 'bottom' , 'left'The tooltip placement of the input.
status'success', 'error'The status of the input. Can be success or error.
size'xs', 'sm' , 'sm'The size of the input. Default is sm. Can be sm or lg.
namestringThe name of the input.
valuestringThe value of the input.
disabledbooleanThe disabled state of the input. Default is false.
requiredbooleanThe required state of the input. Default is false.
readonlybooleanThe readonly state of the input. Default is false.
autofocusbooleanThe autofocus state of the input. Default is false.
minnumberThe minimum value of the number input.
maxnumberThe maximum value of the number input.
stepnumberThe step value of the number input.
feedbackstringThe feedback of the input.
feedbackType'negative', 'positive' , 'warning'The feedback type of the input. Can be negative, positive, or warning.
loadingbooleanThe loading state of the input. Default is false.
optionalbooleanThe optional state of the input.
optionalLabelstringThe optional label of the input.
subtlebooleanThe weight of the label. Default is false
disableEnterbooleanDisables the enter key from being used to submit the form.
Slots
NameDescription
feedback-iconThe custom icon of the feedback.
Events
Event NameDescriptionType
dds-changeFired when the input value changes.{value: string }
dds-inputFired when the input value changes.{value: string }
dds-keydownFired when a key is pressed down.{value: string, originalEvent: Event }
dds-blurFired when the input loses focus.{void }
dds-focusEmitted when the input gains focus.{void }
CSS Parts
Part NameDescription
baseThe main number input container.
inputThe input element.
labelThe label of the input.
descriptionThe description of the input.
feedbackThe feedback of the input.
tooltipThe tooltip of the input.
addon-beforeThe addon before the input.
addon-afterThe addon after the input.
prefixThe prefix of the input.
postfixThe postfix of the input.
decrement-buttonThe decrement button of the input.
increment-buttonThe increment button of the input.
decrement-button-baseThe base of the decrement button.
increment-button-baseThe base of the increment button.
decrement-button-contentThe content of the decrement button.
increment-button-contentThe content of the increment button.
How to Use CSS Parts

You can style CSS parts using the ::part() pseudo-element selector:

/* Target a specific part */
.my-custom-dap-ds-number-input::part(base) {
  /* Your custom styles */
}

/* Target multiple parts */
.my-custom-dap-ds-number-input::part(base),
.my-custom-dap-ds-number-input::part(input) {
  /* Shared styles */
}

Example usage:

<dap-ds-number-input class="my-custom-dap-ds-number-input">
  Number input
</dap-ds-number-input>
.my-custom-dap-ds-number-input::part(base) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.

CSS Custom Properties
Property NameDescription
--dds-input-height-xsThe height of the extra small input. Default is var(--dds-spacing-800).
--dds-input-height-smThe height of the small input. Default is var(--dds-spacing-1000).
--dds-input-height-lgThe height of the large input. Default is var(--dds-spacing-1200).
--dds-input-padding-xsThe padding of the extra small input. Default is 0 var(--dds-spacing-200).
--dds-input-padding-smThe padding of the small input. Default is 0 var(--dds-spacing-300).
--dds-input-padding-lgThe padding of the large input. Default is 0 var(--dds-spacing-400).
--dds-input-font-size-xsThe font size of the extra small input. Default is var(--dds-font-sm).
--dds-input-font-size-smThe font size of the small input. Default is var(--dds-font-base).
--dds-input-font-size-lgThe font size of the large input. Default is var(--dds-font-lg).
--dds-input-borderThe border of the input. Default is var(--dds-border-width-base) solid var(--dds-border-neutral-base).
--dds-input-backgroundThe background color of the input. Default is var(--dds-fields-background-default).
--dds-input-text-colorThe text color of the input. Default is var(--dds-text-neutral-base).
--dds-input-border-radiusThe border radius of the input. Default is var(--dds-radius-base).
--dds-input-disabled-borderThe border of the disabled input. Default is 0 solid var(--dds-border-neutral-disabled).
--dds-input-disabled-backgroundThe background color of the disabled input. Default is var(--dds-fields-background-disabled).
--dds-input-disabled-textThe text color of the disabled input. Default is var(--dds-text-neutral-disabled).
--dds-input-readonly-borderThe border of the readonly input. Default is 0 solid var(--dds-border-neutral-subtle).
--dds-input-readonly-backgroundThe background color of the readonly input. Default is var(--dds-fields-background-read-only).
--dds-input-readonly-textThe text color of the readonly input. Default is var(--dds-text-neutral-subtle).
--dds-input-success-borderThe border of the success input. Default is var(--dds-border-width-base) solid var(--dds-border-positive-base).
--dds-input-error-borderThe border of the error input. Default is var(--dds-border-width-base) solid var(--dds-border-negative-base).
--dds-input-addon-backgroundThe background color of the input addon. Default is var(--dds-fields-background-default).
--dds-input-addon-success-backgroundThe background color of the success input addon. Default is var(--dds-fields-background-default).
--dds-input-addon-error-backgroundThe background color of the error input addon. Default is var(--dds-fields-background-default).
--dds-input-addon-border-beforeThe border of the addon before the input. Default is var(--dds-border-width-base) solid var(--dds-border-neutral-base).
--dds-input-addon-border-afterThe border of the addon after the input. Default is var(--dds-border-width-base) solid var(--dds-border-neutral-base).
--dds-input-addon-border-width-beforeThe border width of the addon before the input. Default is var(--dds-border-width-base) 0 var(--dds-border-width-base) var(--dds-border-width-base).
--dds-input-addon-border-width-afterThe border width of the addon after the input. Default is var(--dds-border-width-base) var(--dds-border-width-base) var(--dds-border-width-base) 0.
--dds-input-addon-success-borderThe border of the success addon. Default is var(--dds-border-width-base) solid var(--dds-border-positive-base).
--dds-input-addon-success-border-beforeThe border of the success addon before the input. Default is var(--dds-border-width-base) solid var(--dds-border-positive-base).
--dds-input-addon-success-border-afterThe border of the success addon after the input. Default is var(--dds-border-width-base) solid var(--dds-border-positive-base).
--dds-input-addon-success-border-width-beforeThe border width of the success addon before the input. Default is var(--dds-border-width-base) 0 var(--dds-border-width-base) var(--dds-border-width-base).
--dds-input-addon-success-border-width-afterThe border width of the success addon after the input. Default is var(--dds-border-width-base) var(--dds-border-width-base) var(--dds-border-width-base) 0.
--dds-input-addon-error-border-beforeThe border of the error addon before the input. Default is var(--dds-border-width-base) solid var(--dds-border-negative-base).
--dds-input-addon-error-border-afterThe border of the error addon after the input. Default is var(--dds-border-width-base) solid var(--dds-border-negative-base).
--dds-input-addon-error-border-width-beforeThe border width of the error addon before the input. Default is var(--dds-border-width-base) 0 var(--dds-border-width-base) var(--dds-border-width-base).
--dds-input-addon-error-border-width-afterThe border width of the error addon after the input. Default is var(--dds-border-width-base) var(--dds-border-width-base) var(--dds-border-width-base) 0.
How to Use CSS Custom Properties

CSS custom properties (CSS variables) can be set directly on the component or in your stylesheet:

Method 1: Inline styles (Quick customization)

<dap-ds-number-input
  style="--dds-input-height-xs: value; --dds-input-height-sm: value;">
  Number input
</dap-ds-number-input>

Method 2: CSS classes (Reusable styles)

.my-custom-dap-ds-number-input {
  --dds-input-height-xs: value;
  --dds-input-height-sm: value;
  --dds-input-height-lg: value;
}
<dap-ds-number-input class="my-custom-dap-ds-number-input">
  Number input
</dap-ds-number-input>

Method 3: Global theme customization

/* Apply to all instances */
dap-ds-number-input {
  --dds-input-height-xs: value;
  --dds-input-height-sm: value;
}

CSS custom properties inherit through the Shadow DOM, making them perfect for theming. Changes apply immediately without rebuilding.