The p-input-number component is a form-associated custom element that integrates seamlessly with forms. Leveraging the
ElementInternals API, it functions like a native
input, ensuring compatibility with form behaviors. However, note that browser support for this API is limited.
In the controlled approach, the p-input-number value is externally managed. While the internal value will be updated
automatically, you can use the input, change or blur event to update the external state.
Sometimes it's useful to be able to render markup (e.g. an anchor tag) for label, description or message.
Therefore, a named slot can be used. Make sure not to define the corresponding property on the host element when a
named slot is used (because a property definition is preferred over a named slot). For named slots only
phrasing content is
allowed.
If you need to provide additional information or actions to the user, you can use the start and end slots. For
example, you might include an icon, a unit, or an action button. Icons and text should use the contrast-medium color
to avoid being mistaken for a button.
If you use a p-button-pure or a p-link-pure, a padding and margin have to be set with the exposed
--ref-p-input-slotted-padding and --ref-p-input-slotted-margin CSS Variables.
Some label with a link.Some description with a link.Some error message with a link.
prev
next
Open in Stackblitz
<!doctype html>
<htmllang="en"class="auto"><head><title></title></head><bodyclass="bg-base"><p-input-numberstate="error"><spanslot="label"id="some-label-id"> Some label with a
<ahref="https://designsystem.porsche.com"> link
</a> .
</span><spanslot="description"id="some-description-id"> Some description with a
<ahref="https://designsystem.porsche.com"> link
</a> .
</span><p-iconslot="start"name="shopping-cart"color="contrast-medium"aria-hidden="true"></p-icon><p-button-pureslot="end"icon="delete"hide-label="true"class="p-(--ref-p-input-slotted-padding) m-(--ref-p-input-slotted-margin)"aria="{'aria-label': 'Delete'}"></p-button-pure><spanslot="message"id="some-message-id"> Some error message with a
<ahref="https://designsystem.porsche.com"> link
</a> .
</span></p-input-number><script></script></body></html>