The Shadcn autocomponents are a set of components that are made using the Shadcn design system and are designed to be used in web apps. These components have the base autocomponent props and the Shadcn design system component overrides.
For more information on the autocomponents, see the @gadgetinc/react/auto references.
Usage
Within a Gadget app made with the web template, import Shadcn autocomponents from the web/components/auto.ts file:
React
import { AutoForm, AutoTable, AutoInput, AutoSubmit } from "../components/auto";
import { AutoForm, AutoTable, AutoInput, AutoSubmit } from "../components/auto";
For example, to use the AutoForm component:
React
import { AutoForm, AutoInput, AutoSubmit } from "../components/auto";
import { api } from "../api";
export default function () {
return (
<AutoForm action={api.widget.create}>
<AutoInput field="name" />
<AutoSubmit />
</AutoForm>
);
}
import { AutoForm, AutoInput, AutoSubmit } from "../components/auto";
import { api } from "../api";
export default function () {
return (
<AutoForm action={api.widget.create}>
<AutoInput field="name" />
<AutoSubmit />
</AutoForm>
);
}
Customization
You can fully customize the base components used to create the Shadcn autocomponents. In the web/components/ui/ folder, there is a collection of component files that are used to create the autocomponents, and these can be easily modified to change the look of the autocomponents.
For example, the default Button component has variants with different styles, and to to change those styles, the original web/components/ui/button.tsx file can be modified.
Now, all buttons used in autocomponents will be made with the customized component. Now when using an autocomponent that uses a button such as <AutoSubmit />, the button will now look like this:
React
import { AutoForm, AutoButton } from "../components/auto";
import { api } from "../api";
export default function () {
return (
<AutoForm action={api.widget.create}>
<AutoInput field="name" />
<AutoSubmit>Primary</AutoSubmit>
</AutoForm>
);
}
import { AutoForm, AutoButton } from "../components/auto";
import { api } from "../api";
export default function () {
return (
<AutoForm action={api.widget.create}>
<AutoInput field="name" />
<AutoSubmit>Primary</AutoSubmit>
</AutoForm>
);
}