Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
adjust field styling and add stories
Scott Wilson2732f3473fdc
diff --git a/frontend/src/components/v3/generic/Field/Field.stories.tsx b/frontend/src/components/v3/generic/Field/Field.stories.tsxnew file mode 100644index 0000000000..48bea4283f--- /dev/null+++ b/frontend/src/components/v3/generic/Field/Field.stories.tsx@@ -0,0 +1,223 @@+import type { Meta, StoryObj } from "@storybook/react-vite";++import { Checkbox } from "../Checkbox";+import { Input } from "../Input";+import { Switch } from "../Switch";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldError,+ FieldGroup,+ FieldLabel,+ FieldLegend,+ FieldSeparator,+ FieldSet,+ FieldTitle+} from "./Field";++/**+ * Field provides the layout primitives for building form controls — label, control,+ * description, and error message — with consistent spacing and accessible markup.+ * Compose a single input with `Field` + `FieldLabel` + a control + optional+ * `FieldDescription` / `FieldError`. Stack multiple fields in a `FieldGroup`, or wrap+ * legal groupings (checkbox sets, fieldsets) in a `FieldSet` with a `FieldLegend`.+ *+ * The `orientation` prop on `Field` switches between `vertical` (default — stacked),+ * `horizontal` (label left, control right), and `responsive` (vertical on narrow+ * containers, horizontal on wider ones).+ */+const meta = {+ title: "Generic/Field",+ component: Field,+ parameters: {+ layout: "centered"+ },+ tags: ["autodocs"],+ argTypes: {+ orientation: {+ control: "select",+ options: ["vertical", "horizontal", "responsive"]+ },+ children: {+ table: {+ disable: true+ }+ },+ className: {+ table: {+ disable: true+ }+ }+ }+} satisfies Meta<typeof Field>;++export default meta;+type Story = StoryObj<typeof meta>;++export const Default: Story = {+ name: "Example: Default",+ parameters: {+ docs: {+ description: {+ story:+ "The baseline field — `FieldLabel`, a control, and an optional `FieldDescription`. The label's `htmlFor` points at the control's `id` so screen readers pair them correctly."+ }+ }+ },+ render: () => (+ <Field className="w-96">+ <FieldLabel htmlFor="field-email">Email</FieldLabel>+ <Input id="field-email" type="email" placeholder="[email protected]" />+ <FieldDescription>+ We'll use this address for sign-in and notifications.+ </FieldDescription>+ </Field>+ )+};++export const WithError: Story = {+ name: "Example: With Error",+ parameters: {+ docs: {+ description: {+ story:+ "Render `FieldError` below the control when validation fails. It accepts either a plain string (via `children`) or an `errors` array from `react-hook-form` — duplicate messages are deduplicated; multiple distinct messages render as a bulleted list."+ }+ }+ },+ render: () => (+ <Field className="w-96">+ <FieldLabel htmlFor="field-email-error">Email</FieldLabel>+ <Input id="field-email-error" type="email" defaultValue="not-an-email" isError aria-invalid />+ <FieldError>Enter a valid email address.</FieldError>+ </Field>+ )+};++export const Horizontal: Story = {+ name: "Example: Horizontal",+ parameters: {+ docs: {+ description: {+ story:+ 'Pass `orientation="horizontal"` for label-left / control-right layouts — common for inline toggle rows in settings panels. Wrap the label + description in a `FieldContent` so both align correctly against the control.'+ }+ }+ },+ render: () => (+ <Field orientation="horizontal" className="w-[420px]">+ <FieldContent>+ <FieldTitle>Multi-factor authentication</FieldTitle>+ <FieldDescription>+ Require a second factor when signing in from a new device.+ </FieldDescription>+ </FieldContent>+ <Switch defaultChecked />+ </Field>+ )+};++export const FieldGroupExample: Story = {+ name: "Example: Field Group",+ parameters: {+ docs: {+ description: {+ story:+ "Stack related fields in a `FieldGroup` for consistent vertical rhythm (`gap-5`). The group also provides the `@container` query context that the `responsive` orientation keys off of."+ }+ }+ },+ render: () => (+ <FieldGroup className="w-96">+ <Field>+ <FieldLabel htmlFor="group-name">Name</FieldLabel>+ <Input id="group-name" defaultValue="Scott Wilson" />+ </Field>+ <Field>+ <FieldLabel htmlFor="group-email">Email</FieldLabel>+ <Input id="group-email" type="email" defaultValue="[email protected]" />+ <FieldDescription>+ Used for sign-in and critical notifications. Cannot be changed.+ </FieldDescription>+ </Field>+ <Field>+ <FieldLabel htmlFor="group-role">Role</FieldLabel>+ <Input id="group-role" defaultValue="Admin" disabled />+ </Field>+ </FieldGroup>+ )+};++export const WithSeparator: Story = {+ name: "Example: With Separator",+ parameters: {+ docs: {+ description: {+ story:+ 'Use `FieldSeparator` with text children ("OR") to split a form into alternate paths — e.g. email/password login above and SSO below.'+ }+ }+ },+ render: () => (+ <FieldGroup className="w-96">+ <Field>+ <FieldLabel htmlFor="separator-email">Email</FieldLabel>+ <Input id="separator-email" type="email" placeholder="[email protected]" />+ </Field>+ <Field>+ <FieldLabel htmlFor="separator-password">Password</FieldLabel>+ <Input id="separator-password" type="password" placeholder="••••••••" />+ </Field>+ <FieldSeparator>OR</FieldSeparator>+ <Field>+ <FieldLabel htmlFor="separator-sso">Company domain</FieldLabel>+ <Input id="separator-sso" placeholder="acme.com" />+ <FieldDescription>+ Enter your organization's domain to sign in with SSO.+ </FieldDescription>+ </Field>+ </FieldGroup>+ )+};++export const FieldSetExample: Story = {+ name: "Example: Field Set",+ parameters: {+ docs: {+ description: {+ story:+ "Wrap related boolean controls in a `FieldSet` with a `FieldLegend` for semantic grouping — the legend serves as a single accessible label for the entire set, and `FieldDescription` right after the legend applies an extra top-negative-margin to tuck it close."+ }+ }+ },+ render: () => (+ <FieldSet className="w-96">+ <FieldLegend>Notifications</FieldLegend>+ <FieldDescription>Choose which events should email you.</FieldDescription>+ <FieldGroup>+ <Field orientation="horizontal">+ <Checkbox id="notify-deploys" defaultChecked />+ <FieldContent>+ <FieldTitle>Deploy events</FieldTitle>+ <FieldDescription>When a deploy completes, fails, or is rolled back.</FieldDescription>+ </FieldContent>+ </Field>+ <Field orientation="horizontal">+ <Checkbox id="notify-access" />+ <FieldContent>+ <FieldTitle>Access changes</FieldTitle>+ <FieldDescription>When roles or permissions change for this project.</FieldDescription>+ </FieldContent>+ </Field>+ <Field orientation="horizontal">+ <Checkbox id="notify-billing" defaultChecked />+ <FieldContent>+ <FieldTitle>Billing updates</FieldTitle>+ <FieldDescription>Invoices, plan changes, and usage alerts.</FieldDescription>+ </FieldContent>+ </Field>+ </FieldGroup>+ </FieldSet>+ )+};diff --git a/frontend/src/components/v3/generic/Field/Field.tsx b/frontend/src/components/v3/generic/Field/Field.tsxindex e492e74185..54d94f9359 100644--- a/frontend/src/components/v3/generic/Field/Field.tsx+++ b/frontend/src/components/v3/generic/Field/Field.tsx@@ -10,7 +10,7 @@ function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {<fieldsetdata-slot="field-set"className={cn(- "flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",+ "m-0 flex min-w-0 flex-col gap-4 border-0 p-0 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",className)}{...props}@@ -28,7 +28,7 @@ function FieldLegend({data-slot="field-legend"data-variant={variant}className={cn(- "mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",+ "mb-1.5 font-medium text-foreground data-[variant=label]:text-sm data-[variant=legend]:text-base",className)}{...props}@@ -109,7 +109,7 @@ function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {<divdata-slot="field-label"className={cn(- "flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",+ "flex w-fit items-center gap-2 text-sm leading-snug font-medium text-foreground group-data-[disabled=true]/field:opacity-50",className)}{...props}@@ -122,9 +122,8 @@ function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {<pdata-slot="field-description"className={cn(- "mt-1 text-left text-xs leading-normal font-normal text-muted group-has-[[data-orientation=horizontal]]/field:text-balance [[data-variant=legend]+&]:-mt-1.5",- "last:mt-0 nth-last-2:-mt-1",- "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",+ "mt-0.5 text-left text-xs leading-snug font-normal text-muted group-has-[[data-orientation=horizontal]]/field:text-balance [[data-variant=legend]+&]:-mt-1.5",+ "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-foreground",className)}{...props}@@ -149,14 +148,16 @@ function FieldSeparator({)}{...props}>- <Separator className="absolute inset-0 top-1/2" />- {children && (- <span- className="text-muted-foreground relative mx-auto block w-fit bg-background px-2"- data-slot="field-separator-content"- >- {children}- </span>+ {children ? (+ <div className="flex items-center gap-3">+ <Separator className="flex-1" />+ <span className="text-xs font-medium text-muted/65" data-slot="field-separator-content">+ {children}+ </span>+ <Separator className="flex-1" />+ </div>+ ) : (+ <Separator className="absolute inset-0 top-1/2" />)}</div>);@@ -202,7 +203,7 @@ function FieldError({<divrole="alert"data-slot="field-error"- className={cn("mt-1 text-xs font-normal text-danger", className)}+ className={cn("mt-0.5 text-xs leading-snug font-normal text-danger", className)}{...props}>{content}diff --git a/frontend/src/components/v3/generic/Input/Input.tsx b/frontend/src/components/v3/generic/Input/Input.tsxindex 81cb0df839..15fd32c7f5 100644--- a/frontend/src/components/v3/generic/Input/Input.tsx+++ b/frontend/src/components/v3/generic/Input/Input.tsx@@ -10,7 +10,7 @@ const Input = forwardRef<HTMLInputElement, React.ComponentProps<"input"> & { isEtype={type}data-slot="input"className={cn(- "h-9 w-full min-w-0 rounded-md border border-border bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",+ "h-9 w-full min-w-0 rounded-md border border-border bg-transparent px-3 py-1 text-sm text-foreground shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-invalid:border-danger aria-invalid:ring-danger/40","selection:bg-foreground selection:text-background",