carbon-components-svelte/docs/src/pages/framed/NumberInput/NumberInputEmpty.svelte
jqlio18 faddb4c654 1. We should verify if the input is in an error state onMount and set the error accordingly.
2. Fix last commits and the `invalid` state border works again.
3. If the `invalid` state is set by the user, we must use `setCustomValidity` to set input validity to false.
4. `invalidText` must have a default and must not be empty. If empty, it will set the validity to true. I don't know if we should check for that.
2022-12-13 17:42:00 -05:00

23 lines
552 B
Svelte

<script>
import { NumberInput, Button } from "carbon-components-svelte";
let value = null;
let invalid = false;
</script>
<NumberInput required="{false}" bind:value="{value}" invalid="{invalid}" />
<div style="margin: var(--cds-layout-01) 0">
<Button on:click="{() => (value = null)}">Set to null</Button>
<Button on:click="{() => (value = 0)}">Set to 0</Button>
<Button on:click="{() => (invalid = !invalid)}">Toggle invalid</Button>
</div>
<p>
<strong>Value:</strong>
{value}
</p>
<p>
<strong>Invalid:</strong>
{invalid}
</p>