Skip to content
silverpoint
Documentation menu

UI components · Data entry

Input

A native text input in a framed box. Group: Data entry · component 2 of 17, new in silverpoint 0.3.
size="lg"
mode="precision"
substrate="green"

States

The 4 reference states silverpoint declares for Input, live on both grounds, with their code. As in upstream's documentation the examples are uncontrolled: the state's value is the default value. Pick a framework once and every example on the site follows it.

empty

silverpoint · cream
cyanotype · prussian
tsx
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpInput } from '@silverpoint/react/ui/input';

<SpInput
  label="Search charts"
  placeholder="Search charts…"
  type="search"
  name="q"
  defaultValue=""
/>

filled

silverpoint · cream
cyanotype · prussian
tsx
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpInput } from '@silverpoint/react/ui/input';

<SpInput label="City" name="city" defaultValue="Caracas" />

invalid

Required: pick a city
silverpoint · cream
Required: pick a city
cyanotype · prussian
tsx
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpInput } from '@silverpoint/react/ui/input';

<SpInput
  label="City"
  name="city"
  invalid
  message="Required: pick a city"
  defaultValue="Caracas"
/>

disabled

silverpoint · cream
cyanotype · prussian
tsx
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpInput } from '@silverpoint/react/ui/input';

<SpInput label="City" name="city" disabled defaultValue="Caracas" />

Import

Each component has its own subpath under ui/, and every adapter exports them all from ui. Import @silverpoint/grounds/ui.css once, beside styles.css; Reflex adds it for you.

FrameworkImport
Reactimport { SpInput } from '@silverpoint/react/ui/input';
Vueimport { SpInput } from '@silverpoint/vue/ui/input';
Angularimport { SpInput } from '@silverpoint/angular/ui/input'; // <sp-input>
Reflexfrom reflex_silverpoint_react import sp_input

Binding the value

Controlled or uncontrolled, the way each framework does it. The change event carries the new value itself (a string, a bool or a number), never a DOM event.

FrameworkControlledUncontrolled
Reactvalue / onChangedefaultValue
Vuev-model="x"default-value
Angular[(value)]="x", ngModel, formControl[defaultValue]
Reflexvalue=State.x, on_change=State.set_xdefault_value=…

Props

The props Input adds to the ones every UI component takes.

React / AngularVueReflexTypeDescription
typetypetypeLiteral['text', 'search', 'email', 'url', 'tel', 'password', 'number']Native input type: text (default), search, email, url, tel, password, number.
placeholderplaceholderplaceholderstrHint shown while empty; not a substitute for the accessible name.
namenamenamestrForm field name; the native input submits under it.
disableddisableddisabledboolNot focusable and not submitted.
readOnlyread-onlyread_onlyboolFocusable and submitted, but not editable.
invalidinvalidinvalidboolSets aria-invalid and draws the exact ⚠ glyph.
messagemessagemessagestrHelp or error text under the control, referenced by aria-describedby.
labellabellabelstrAccessible name, when no <label for> names the control.
valuevaluevaluestrControlled value.
defaultValuedefault-valuedefault_valuestrInitial value of an uncontrolled input.
prefixprefixprefixComponentContent before the text, inside the box.
suffixsuffixsuffixComponentContent after the text, inside the box.
onChangeon-changeon_changeeventThe new value (a string), not the DOM event.

Common props

Every UI component also takes these. Like a chart's, they fall back to the dashboard the component sits in, then to the provider. Read more about the UI components.

React / AngularVueReflexTypeDescription
idididstrThe frame variant and every related id derive from it.
groundgroundgroundLiteral['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.
substratesubstratesubstrateLiteral['cream', 'green', 'blue', 'ochre', 'prussian']Prepared substrate within the ground.
modemodemodeLiteral['ink', 'precision']ink by default; precision disables inking.
seedseedseedstr | intSeed of the frame's hand; overrides id for the frame variant only.
sizesizesizeLiteral['sm', 'md', 'lg']Control size: sm, md (default) or lg.
palettepalettepalettedict[str, str]Colours over the ground's (set with palette=), merged over the dashboard's and the provider's.
classNameclass-nameclass_namestrAdded to the component's root element, after its own classes.
Report it
Found something wrong with SpInput? Open an issue on GitHub — the form comes pre-filled with the component and the version.