Docs Components Primitives

Field

React example follows below.
ts
import { inputControlClass } from "@grassroot/ui-core";
import { Field } from "@grassroot/ui-react";
export default function FieldDemo() {
return (
<div className="flex flex-col gap-3.5">
<Field label="Repository" htmlFor="react-repo" hint="Owner/name of the GitHub repository.">
<input
id="react-repo"
placeholder="grassroot/platform"
className={inputControlClass(false, false)}
/>
</Field>
<Field label="Branch" htmlFor="react-branch" required error="That branch could not be found.">
<input id="react-branch" placeholder="main" className={inputControlClass(false, true)} />
</Field>
</div>
);
}
ts
<script setup lang="ts">
import { inputControlClass } from "@grassroot/ui-core";
import { Field } from "@grassroot/ui-vue";
</script>
<template>
<div class="flex flex-col gap-3.5">
<Field label="Repository" html-for="vue-repo" hint="Owner/name of the GitHub repository.">
<input id="vue-repo" placeholder="grassroot/platform" :class="inputControlClass(false, false)" />
</Field>
<Field label="Branch" html-for="vue-branch" required error="That branch could not be found.">
<input id="vue-branch" placeholder="main" :class="inputControlClass(false, true)" />
</Field>
</div>
</template>
ts
import { Component } from "@angular/core";
import { inputControlClass } from "@grassroot/ui-core";
import { GrassrootField } from "@grassroot/ui-angular";
@Component({
selector: "app-field-demo",
standalone: true,
imports: [GrassrootField],
host: { style: "display: contents" },
template: `
<div class="flex flex-col gap-3.5">
<grassroot-field
label="Repository"
htmlFor="angular-repo"
hint="Owner/name of the GitHub repository."
>
<input id="angular-repo" placeholder="grassroot/platform" [class]="controlClass" />
</grassroot-field>
<grassroot-field
label="Branch"
htmlFor="angular-branch"
[required]="true"
error="That branch could not be found."
>
<input id="angular-branch" placeholder="main" [class]="errorControlClass" />
</grassroot-field>
</div>
`,
})
export class FieldDemoComponent {
protected readonly controlClass = inputControlClass(false, false);
protected readonly errorControlClass = inputControlClass(false, true);
}
export default FieldDemoComponent;
ts
<script lang="ts">
import { inputControlClass } from "@grassroot/ui-core";
import { Field } from "@grassroot/ui-svelte";
</script>
<div class="flex flex-col gap-3.5">
<Field label="Repository" htmlFor="svelte-repo" hint="Owner/name of the GitHub repository.">
<input id="svelte-repo" placeholder="grassroot/platform" class={inputControlClass(false, false)} />
</Field>
<Field label="Branch" htmlFor="svelte-branch" required error="That branch could not be found.">
<input id="svelte-branch" placeholder="main" class={inputControlClass(false, true)} />
</Field>
</div>
ts
/** @jsxImportSource solid-js */
import { inputControlClass } from "@grassroot/ui-core";
import { Field } from "@grassroot/ui-solid";
export default function FieldDemo() {
return (
<div class="flex flex-col gap-3.5">
<Field label="Repository" htmlFor="solid-repo" hint="Owner/name of the GitHub repository.">
<input
id="solid-repo"
placeholder="grassroot/platform"
class={inputControlClass(false, false)}
/>
</Field>
<Field label="Branch" htmlFor="solid-branch" required error="That branch could not be found.">
<input id="solid-branch" placeholder="main" class={inputControlClass(false, true)} />
</Field>
</div>
);
}

Installation

API Reference

Import

import { inputControlClass } from "@grassroot/ui-core";
import { Field } from "@grassroot/ui-react";

Props

Prop
Type
Default
Requirement
Description
label
string | undefined
optional
Mono uppercase label rendered above control.
htmlFor
string | undefined
optional
id the control label points at.
required
boolean | undefined
false
optional
Mark field required (crimson asterisk on label).
hint
string | undefined
optional
Helper text below control.
error
string | undefined
optional
Error message replaces hint and turns crimson.
Prop
label
Type
string | undefined
Default
Requirement
optional
Description
Mono uppercase label rendered above control.
Prop
htmlFor
Type
string | undefined
Default
Requirement
optional
Description
id the control label points at.
Prop
required
Type
boolean | undefined
Default
false
Requirement
optional
Description
Mark field required (crimson asterisk on label).
Prop
hint
Type
string | undefined
Default
Requirement
optional
Description
Helper text below control.
Prop
error
Type
string | undefined
Default
Requirement
optional
Description
Error message replaces hint and turns crimson.

Content regions

  • children
  • footer

Native attributes

Standard DOM and ARIA attributes not listed above spread onto the root element.

Import

import { inputControlClass } from "@grassroot/ui-core";
import { Field } from "@grassroot/ui-vue";

Props

Prop
Type
Default
Requirement
label
string | undefined
optional
htmlFor
string | undefined
optional
required
boolean | undefined
optional
hint
string | undefined
optional
error
string | undefined
optional
Prop
label
Type
string | undefined
Default
Requirement
optional
Prop
htmlFor
Type
string | undefined
Default
Requirement
optional
Prop
required
Type
boolean | undefined
Default
Requirement
optional
Prop
hint
Type
string | undefined
Default
Requirement
optional
Prop
error
Type
string | undefined
Default
Requirement
optional
Prop
footer
Type
string | undefined
Default
Requirement
optional

Content regions

  • default
  • footer

Import

import { Component } from "@angular/core";
import { inputControlClass } from "@grassroot/ui-core";
import { GrassrootField } from "@grassroot/ui-angular";

Props

Prop
Type
Default
Requirement
label
string
optional
htmlFor
string
optional
required
boolean
false
optional
hint
string
optional
error
string
optional
Prop
label
Type
string
Default
Requirement
optional
Prop
htmlFor
Type
string
Default
Requirement
optional
Prop
required
Type
boolean
Default
false
Requirement
optional
Prop
hint
Type
string
Default
Requirement
optional
Prop
error
Type
string
Default
Requirement
optional
Prop
footer
Type
string
Default
Requirement
optional

Content regions

  • default
  • footer

Import

import { inputControlClass } from "@grassroot/ui-core";
import { Field } from "@grassroot/ui-svelte";

Props

Prop
Type
Default
Requirement
label
string
optional
htmlFor
string
optional
required
boolean
false
optional
hint
string
optional
error
string
optional
className
string
optional
Prop
label
Type
string
Default
Requirement
optional
Prop
htmlFor
Type
string
Default
Requirement
optional
Prop
required
Type
boolean
Default
false
Requirement
optional
Prop
hint
Type
string
Default
Requirement
optional
Prop
error
Type
string
Default
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional

Content regions

  • children
  • footer

Import

import { inputControlClass } from "@grassroot/ui-core";
import { Field } from "@grassroot/ui-solid";

Props

Prop
Type
Default
Requirement
label
string
optional
htmlFor
string
optional
required
boolean
optional
hint
string
optional
error
string
optional
className
string
optional
Prop
label
Type
string
Default
Requirement
optional
Prop
htmlFor
Type
string
Default
Requirement
optional
Prop
required
Type
boolean
Default
Requirement
optional
Prop
hint
Type
string
Default
Requirement
optional
Prop
error
Type
string
Default
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional

Content regions

  • children
  • footer