CLI previewInstall commands shown on this site are not released yet.

DocsComponentsPrimitives

Field

React example follows below.
ts
import { Field } from "@grassroot/ui-react";
<Field label="Repository" htmlFor="repo" hint="Owner/name of the GitHub repository.">
<input id="repo" placeholder="grassroot/platform" />
</Field>
<Field label="Branch" htmlFor="branch" required error="That branch could not be found.">
<input id="branch" placeholder="main" />
</Field>
ts
<script setup lang="ts">
import { Field } from "@grassroot/ui-vue";
</script>
<template>
<Field
label="Repository"
html-for="repo"
hint="Owner/name of the GitHub repository."
>
<input id="repo" placeholder="grassroot/platform" />
</Field>
<Field
label="Branch"
html-for="branch"
required
error="That branch could not be found."
>
<input id="branch" placeholder="main" />
</Field>
</template>
ts
import { Component } from "@angular/core";
import { GrassrootField } from "@grassroot/ui-angular";
@Component({
selector: "app-example",
standalone: true,
imports: [GrassrootField],
template: `
<grassroot-field
label="Repository"
htmlFor="repo"
hint="Owner/name of the GitHub repository."
>
<input id="repo" placeholder="grassroot/platform" />
</grassroot-field>
<grassroot-field
label="Branch"
htmlFor="branch"
[required]="true"
error="That branch could not be found."
>
<input id="branch" placeholder="main" />
</grassroot-field>
`,
})
export class ExampleComponent {
}
ts
<script lang="ts">
import { Field } from "@grassroot/ui-svelte";
</script>
<Field
label="Repository"
htmlFor="repo"
hint="Owner/name of the GitHub repository."
>
<input id="repo" placeholder="grassroot/platform" />
</Field>
<Field
label="Branch"
htmlFor="branch"
required
error="That branch could not be found."
>
<input id="branch" placeholder="main" />
</Field>
ts
import { Field } from "@grassroot/ui-solid";
export function Example() {
return (
<>
<Field
label="Repository"
htmlFor="repo"
hint="Owner/name of the GitHub repository."
>
<input id="repo" placeholder="grassroot/platform" />
</Field>
<Field
label="Branch"
htmlFor="branch"
required
error="That branch could not be found."
>
<input id="branch" placeholder="main" />
</Field>
</>
);
}

Installation

bash
pnpm dlx grassroot add ui/field
bash
npx grassroot@latest add ui/field
bash
yarn dlx grassroot add ui/field
bash
bunx grassroot add ui/field

API Reference

FieldProps
PropTypeDefault
labelMono uppercase label rendered above control.string | undefined
htmlForid the control label points at.string | undefined
requiredMark field required (crimson asterisk on label).boolean | undefinedfalse
hintHelper text below control.string | undefined
errorError message replaces hint and turns crimson.string | undefined
footerCustom footer below the control. Defaults to FieldHint.React.ReactNode