shadimage
mksingh
componentjsonforms-controlsource: ok · hit

Jsonforms Control

JSONForms text input renderer for string type fields.

npx shadcn add "https://mksingh.dev/r/jsonforms-control.json"
free

No selection tags yet — empty means no evidence, not lack of support.

Dependencies

Bundle weight · light
@jsonforms/core@jsonforms/react

Registry dependencies

https://mksingh.dev/r/typography.jsoninput

Files1 · source cached 10/15/2026, 4:44:15 AM

registry/forms/renderers/control.tsx
import { useState } from 'react';

import { ControlProps, isControl, rankWith } from '@jsonforms/core';
import { withJsonFormsControlProps } from '@jsonforms/react';

import Typography from '~/components/ui/typography';
import { Input } from '~/components/ui/input';
import { Label } from '~/components/ui/label';
import { shouldShowError } from '~/components/forms/utils';

const ControlRenderer = (props: ControlProps) => {
    const { label, data, handleChange, path, visible, enabled, errors, config } = props;
    const [touched, setTouched] = useState(false);

    if (!visible) return null;

    return (
        <div className="flex flex-col gap-1 py-2">
            {label && <Label className="text-xs font-medium text-foreground">{label}</Label>}
            <Input
                value={data ?? ''}
                onChange={e => handleChange(path, e.target.value)}
                onBlur={() => setTouched(true)}
                disabled={!enabled}
            />
            {shouldShowError(config, touched) && errors && <Typography variant="error">{errors.split("\n")[0]}</Typography>}
        </div>
    );
};

export const controlTester = rankWith(10, isControl);
export default withJsonFormsControlProps(ControlRenderer);

More from mksingh

Browse all components in this library →