Skip to content

Common controls for local React state

Common controls let you build inputs, switch panels, and recover from render failures using ordinary React state, without binding values to an Arc command. Use them for local UI choices and forms whose values your component owns. Import them from @cratis/components/Common:

import { Button, ComboBox, DatePickerInput, TextInput } from '@cratis/components/Common';

CratisComponentsProvider is also re-exported here, but the conventional import is the package root, @cratis/components. Mount it once at the application root to supply the locale and Components-owned labels; see CratisComponentsProvider.

For value controls, your component supplies the current value and handles changes. The control does not save that value or execute an Arc command for you. When the value belongs to an Arc command, use the matching CommandForm field instead of wiring a Common control to the command yourself.

You want to… Use Reference
Enter free text on one or several lines TextInput, TextArea Basic controls
Enter a number with locale separators, fraction rules, bounds, or a nullable value NumberInput Locale-aware number input
Enter a date or a date and time DatePickerInput DatePickerInput
Put an icon addon in front of your own input FormElement FormElement
You want to… Use Reference
Turn one option on or off Checkbox or Switch Basic controls
Pick one of a few options that are all visible Radio, or ToggleGroup for a segmented control Basic controls, Collection controls
Pick one entity by typing to search, with loading, empty, failure and add-new states ComboBox ComboBox
Pick one or more values from a known, small list Dropdown (separate subpath) Dropdown
Edit a set of values as removable tags TagGroup Collection controls
You want to… Use Reference
Run one action Button, or IconButton for an icon-only action Basic controls
Show a row of page-level command actions ActionMenubar ActionMenubar
Switch between content panels owned by the control Tabs Collection controls
Show where the user is in a hierarchy Breadcrumbs Collection controls
Give a routed view a full-height layout and title Page Page
Group content in a bounded div, section, or article Surface Basic controls
Show a short hint on hover and keyboard focus of one element Tooltip Tooltips
You want to… Use Reference
Pass an icon as a React node or icon-font class Icon, IconDisplay Icon
Set the locale, owned labels, icons, or the app-wide toaster CratisComponentsProvider CratisComponentsProvider
Isolate a section’s render failure and offer a user-triggered retry ErrorBoundary ErrorBoundary

Modal content, confirmations, and busy states are in the separate Dialogs subpath. For choices that span several subpaths, such as a table versus a data page, see Choosing a component. To restyle any of these controls, start with the Styling overview.