UI components · Composed · new in 0.7
SpInputNumber
Live
Drawn here with the Reflex version, sp_input_number, on the ground you pick:
Code
The same example in each framework; pick one once and every example on the site follows it.
import { useState } from 'react';
import { SpInputNumber } from '@silverpoint/react/ui/input-number';
export function Copies() {
const [copies, setCopies] = useState<number | null>(3); // null is an empty field
return <SpInputNumber label="Copies" value={copies} onChange={setCopies} min={1} max={10} />;
}<script setup lang="ts">
import { ref } from 'vue';
import { SpInputNumber } from '@silverpoint/vue/ui/input-number';
const copies = ref<number | null>(3);
</script>
<template>
<SpInputNumber v-model="copies" label="Copies" :min="1" :max="10" />
</template>import { Component, signal } from '@angular/core';
import { SpInputNumber } from '@silverpoint/angular/ui/input-number';
@Component({
selector: 'app-copies',
imports: [SpInputNumber],
template: `<sp-input-number [(value)]="copies" label="Copies" [min]="1" [max]="10" />`,
})
export class Copies {
protected readonly copies = signal<number | null>(3);
}sp_input_number(label="Copies", value=State.copies, on_change=State.set_copies, min=1, max=10)Import
Import @silverpoint/grounds/ui.css once, beside styles.css; Reflex adds it for you. Every adapter also exports it from the ui barrel.
| Framework | Import |
|---|---|
| React | import { SpInputNumber } from '@silverpoint/react/ui/input-number'; |
| Vue | import { SpInputNumber } from '@silverpoint/vue/ui/input-number'; |
| Angular | import { SpInputNumber } from '@silverpoint/angular/ui/input-number'; · sp-input-number |
| Reflex | from reflex_silverpoint_react import sp_input_number |
Events, values and slots
Each framework's own way. A change carries the new value itself (a key, a page, a number, a bool), never a DOM event.
| React | Vue | Angular | Reflex | |
|---|---|---|---|---|
| Value | value + onChange(number | null), or defaultValue | v-model | [(value)], ngModel, formControl | value + on_change |
Props
| React / Angular | Vue | Type | Description |
|---|---|---|---|
min | min | number | The lowest value; the value is clamped to it. |
max | max | number | The highest value; the value is clamped to it. |
step | step | number | Default 1. |
precision | precision | number | Decimals. |
placeholder | placeholder | string | Hint shown while empty; not a substitute for the accessible name. |
label | label | string | Accessible name, when no <label for> names the control. |
message | message | string | Help or error text under the control, referenced by aria-describedby. |
invalid | invalid | boolean | Sets aria-invalid and draws the exact ⚠ glyph. |
disabled | disabled | boolean | Not focusable and not submitted; the steppers are disabled too. |
readOnly | read-only | boolean | Focusable and submitted, but not editable. |
name | name | string | Form field name; the native input submits under it. |
decrementLabel | decrement-label | string | Default 'Decrease'. |
incrementLabel | increment-label | string | Default 'Increase'. |
In Reflex the names are snake_case; the Reflex column of Composed components shows the builder's arguments.
Common props
Every UI component also takes these, falling back to the dashboard it sits in, then to the provider. In Reflex they read silverpoint_provider too; only sp_trigger does not: pass them to it.
| React / Angular | Vue | Reflex | Type | Description |
|---|---|---|---|---|
id | id | id | str | The frame variant and every related id derive from it. |
ground | ground | ground | Literal['silverpoint', 'cyanotype'] | str | dict[str, Any] | Style ground: "silverpoint" or "cyanotype", or a ground object. Defaults to the dashboard's, then the provider's, or silverpoint. |
substrate | substrate | substrate | Literal['cream', 'green', 'blue', 'ochre', 'prussian'] | Prepared substrate within the ground. |
mode | mode | mode | Literal['ink', 'precision'] | ink by default; precision disables inking. |
seed | seed | seed | str | int | Seed of the frame's hand; overrides id for the frame variant only. |
size | size | size | Literal['sm', 'md', 'lg'] | Control size: sm, md (default) or lg. |
palette | palette | palette | dict[str, str] | Colours over the ground's (set with palette=), merged over the dashboard's and the provider's. |
className | class-name | class_name | str | Added to the component's root element, after its own classes. |
palette | palette | palette | Palette | Colours over the ground's, merged over the dashboard's and the provider's. |