Skip to content
Nitro Kitv2.0.0.alpha.4

Search gallery…

IntroductionGalleryAgent guideGalleryHuman guideGalleryColorsFoundations · ThemeTypographyFoundations · ThemeSpacing & sizingFoundations · ThemeEffectsFoundations · ThemeButtonComponents · ActionsButton groupComponents · ActionsButton toComponents · ActionsAppearance pickerComponents · FormsCheckboxComponents · FormsCheckbox groupComponents · FormsComboboxComponents · FormsControl groupComponents · FormsDropzoneComponents · FormsFieldComponents · FormsField groupComponents · FormsFieldsetComponents · FormsInputComponents · FormsLabelComponents · FormsRadio buttonComponents · FormsRadio button groupComponents · FormsRich text areaComponents · FormsSelectComponents · FormsSwitchComponents · FormsTextareaComponents · FormsCommand paletteComponents · OverlaysDialogComponents · OverlaysDropdownComponents · OverlaysSheetComponents · OverlaysTooltipComponents · OverlaysAlertComponents · FeedbackEmpty stateComponents · FeedbackToastComponents · FeedbackAccordionComponents · Data displayAvatarComponents · Data displayAvatar stackComponents · Data displayBadgeComponents · Data displayDetails tableComponents · Data displayIconComponents · Data displayProgressive imageComponents · Data displayStat gridComponents · Data displayTableComponents · Data displayTypesetComponents · Data displayPaginationComponents · NavigationPagination barComponents · NavigationTabsComponents · NavigationToolbarComponents · NavigationCardComponents · LayoutContainerComponents · LayoutFlexComponents · LayoutGridComponents · LayoutApplication navigationComponents · ApplicationApplication shellComponents · ApplicationAuthentication shellComponents · ApplicationDanger zoneComponents · ApplicationData sectionComponents · ApplicationForm sectionComponents · ApplicationPage headerComponents · ApplicationSettings layoutComponents · ApplicationSign inCompositions · Access & onboardingPassword resetCompositions · Access & onboardingEmail verificationCompositions · Access & onboardingInvitation acceptanceCompositions · Access & onboardingAccount creationCompositions · Access & onboardingAccount securityCompositions · Access & onboardingWorkspace onboardingCompositions · Access & onboardingBranched onboardingCompositions · Access & onboardingWorkspace dashboardCompositions · Workspace & organizationWorkspace settingsCompositions · Workspace & organizationWorkspace usersCompositions · Workspace & organizationTeam managementCompositions · Workspace & organizationAPI credentialsCompositions · Workspace & organizationOrganization overviewCompositions · Workspace & organizationOrganization settingsCompositions · Workspace & organizationTeam activityCompositions · Workspace & organizationTeam memberCompositions · Workspace & organizationSubscription billingCompositions · Billing & commerceCheckout and paymentCompositions · Billing & commerceCheckout resultsCompositions · Billing & commerceData resource overviewCompositions · Data & operationsData resource activityCompositions · Data & operationsData resource settingsCompositions · Data & operationsProduct resource lifecycleCompositions · Data & operationsAPI webhooksCompositions · Data & operationsIntegration managementCompositions · Data & operationsFile uploadsCompositions · Data & operationsActivity and audit logCompositions · Data & operationsChangelogCompositions · Product & supportHelp centerCompositions · Product & supportSystem status and errorsCompositions · Product & supportProduct landingCompositions · MarketingPublic pricingCompositions · MarketingProduct featuresCompositions · MarketingPublic contactCompositions · MarketingSidebar operations applicationCompositions · Complete applicationsTopbar media applicationCompositions · Complete applicationsHybrid account applicationCompositions · Complete applications

No destinations found.

  • Introduction
  • Agent guide
  • Human guide
  • Foundations
    • Colors
    • Typography
    • Spacing & sizing
    • Effects
  • Actions
    • Button
    • Button group
    • Button to
  • Forms
    • Appearance picker
    • Checkbox
    • Checkbox group
    • Combobox
    • Control group
    • Dropzone
    • Field
    • Field group
    • Fieldset
    • Input
    • Label
    • Radio button
    • Radio button group
    • Rich text area
    • Select
    • Switch
    • Textarea
  • Overlays
    • Command palette
    • Dialog
    • Dropdown
    • Sheet
    • Tooltip
  • Feedback
    • Alert
    • Empty state
    • Toast
  • Data display
    • Accordion
    • Avatar
    • Avatar stack
    • Badge
    • Details table
    • Icon
    • Progressive image
    • Stat grid
    • Table
    • Typeset
  • Navigation
    • Pagination
    • Pagination bar
    • Tabs
    • Toolbar
  • Layout
    • Card
    • Container
    • Flex
    • Grid
  • Application
    • Application navigation
    • Application shell
    • Authentication shell
    • Danger zone
    • Data section
    • Form section
    • Page header
    • Settings layout
  • Access & onboarding
    • Sign in
    • Password reset
    • Email verification
    • Invitation acceptance
    • Account creation
    • Account security
    • Workspace onboarding
    • Branched onboarding
  • Workspace & organization
    • Workspace dashboard
    • Workspace settings
    • Workspace users
    • Team management
    • API credentials
    • Organization overview
    • Organization settings
    • Team activity
    • Team member
  • Billing & commerce
    • Subscription billing
    • Checkout and payment
    • Checkout results
  • Data & operations
    • Data resource overview
    • Data resource activity
    • Data resource settings
    • Product resource lifecycle
    • API webhooks
    • Integration management
    • File uploads
    • Activity and audit log
  • Product & support
    • Changelog
    • Help center
    • System status and errors
  • Marketing
    • Product landing
    • Public pricing
    • Product features
    • Public contact
  • Complete applications
    • Sidebar operations application
    • Topbar media application
    • Hybrid account application

Field

Labels, descriptions, controls, and validation errors as one accessible unit.

Source
app/components/nitro_kit/field.rb
API
NitroKit::Field.new(form, name, label:, description:, errors:)

Control modes

One field contract composes labels and descriptions around native control types.

Text controls

Text
Visible to everyone in the workspace.
Textarea
ViewportFull width
Rubytest/dummy/app/components/gallery/components/field_page.rb
sample("Text", slug: "text") do
  render NitroKit::Field.new(
    nil,
    :workspace_name,
    id: "gallery-field-text",
    value: "Mothership",
    label: "Workspace name",
    description: "Visible to everyone in the workspace.",
    required: true,
    html: { id: "gallery-field-text-wrapper" }
  )
end
sample("Textarea", slug: "textarea") do
  render NitroKit::Field.new(
    nil,
    :bio,
    as: :textarea,
    id: "gallery-field-textarea",
    value: "Building reliable interfaces for analytical software.",
    label: "Biography",
    html: { id: "gallery-field-textarea-wrapper" }
  )
end

Choice controls

Select
Radio group
Default member role
ViewportFull width
Rubytest/dummy/app/components/gallery/components/field_page.rb
sample("Select", slug: "select") do
  render NitroKit::Field.new(
    nil,
    :time_zone,
    as: :select,
    id: "gallery-field-select",
    value: "Europe/Copenhagen",
    label: "Time zone",
    prompt: "Choose a time zone",
    options: Gallery::Forms::Profile::TIME_ZONES,
    html: { id: "gallery-field-select-wrapper" }
  )
end
sample("Radio group", slug: "radio-group") do
  render NitroKit::Field.new(
    nil,
    :role,
    as: :radio_group,
    id: "gallery-field-radio-group",
    value: "member",
    label: "Default member role",
    options: [ [ "Administrator", "admin" ], [ "Member", "member" ], [ "Viewer", "viewer" ] ],
    html: { id: "gallery-field-radio-group-wrapper" }
  )
end

Boolean controls

Checkbox
Includes deployments, invitations, and billing events.
Switch
Notify the operations channel after every production deploy.
ViewportFull width
Rubytest/dummy/app/components/gallery/components/field_page.rb
sample("Checkbox", slug: "checkbox") do
  render NitroKit::Field.new(
    nil,
    :weekly_digest,
    as: :checkbox,
    id: "gallery-field-checkbox",
    checked: true,
    label: "Send a weekly digest",
    description: "Includes deployments, invitations, and billing events.",
    html: { id: "gallery-field-checkbox-wrapper" }
  )
end
sample("Switch", slug: "switch") do
  render NitroKit::Field.new(
    nil,
    :deployment_alerts,
    as: :switch,
    id: "gallery-field-switch",
    checked: true,
    label: "Deployment alerts",
    description: "Notify the operations channel after every production deploy.",
    html: { id: "gallery-field-switch-wrapper" }
  )
end

States

Required, disabled, and invalid state is visible on the field and connected control.

Availability and validation

Required
Disabled
Invalid
Used for security notices and account recovery.
  • Email is invalid
Viewport640 px · sm
Rubytest/dummy/app/components/gallery/components/field_page.rb
sample("Required", slug: "required") do
  render NitroKit::Field.new(
    nil,
    :email,
    as: :email,
    id: "gallery-field-required",
    value: "[email protected]",
    label: "Account email",
    required: true,
    html: { id: "gallery-field-required-wrapper" }
  )
end
sample("Disabled", slug: "disabled") do
  render NitroKit::Field.new(
    nil,
    :legacy_id,
    id: "gallery-field-disabled",
    value: "acct_legacy_42",
    label: "Legacy account ID",
    disabled: true,
    html: { id: "gallery-field-disabled-wrapper" }
  )
end
sample("Invalid", slug: "invalid") do
  invalid_profile = Gallery::FormExamples.profile(:invalid)
  render NitroKit::Field.new(
    nil,
    :email,
    as: :email,
    id: "gallery-field-invalid",
    value: invalid_profile.email,
    label: "Account email",
    description: "Used for security notices and account recovery.",
    errors: invalid_profile.errors.full_messages_for(:email),
    required: true,
    html: { id: "gallery-field-invalid-wrapper" }
  )
end

Placement parents

A Field owns its label, description, error, and one control, and nothing outside itself. Everything between fields belongs to a parent. FieldGroup — `form.group` on the builder — is the default vertical rhythm owner for bare fields and actions; two bare siblings stack flush. Fieldset provides that rhythm for its direct field, group, and submit children while adding native grouping: reach for it when a set of fields needs one shared accessible name, and take the legend and description it brings with it. SettingsSection is also optional and is the page-level region above the form: a titled header, an optional status Alert, and exactly one form. Flex and Grid own placement when an arrangement is deliberately inline or multi-column.

Section, fieldset, and group together

The section titles the region, the fieldset names the related address fields, and each FieldGroup owns the gap between the controls it contains.

Billing contact

Invoices and receipts are sent to this contact.

Tax registration

Required for workspaces billed inside the EU.

ViewportFull width
Rubytest/dummy/app/components/gallery/components/field_page.rb
render NitroKit::SettingsSection.new(
  title: "Billing contact",
  description: "Invoices and receipts are sent to this contact.",
  id: "gallery-field-placement-section"
) do |section|
  section.form do
    billing = Gallery::FormExamples.billing_contact

    form_with(
      model: billing,
      scope: :billing_contact,
      url: "#billing-contact",
      builder: NitroKit::FormBuilder,
      id: "gallery-field-placement-form"
    ) do |form|
      form.group do
        form.field(:company_name, id: "gallery-field-placement-company", label: "Company name", required: true)
        form.field(:billing_email, as: :email, id: "gallery-field-placement-email", label: "Billing email")
      end

      render NitroKit::Fieldset.new(
        legend: "Tax registration",
        description: "Required for workspaces billed inside the EU.",
        html: { id: "gallery-field-placement-fieldset" }
      ) do
        form.group do
          form.field(
            :country,
            as: :select,
            id: "gallery-field-placement-country",
            label: "Country",
            options: [ [ "Denmark", "DK" ], [ "Germany", "DE" ], [ "United States", "US" ] ]
          )
          form.field(:tax_id, id: "gallery-field-placement-tax-id", label: "Tax ID")
        end
      end

      form.submit("Save billing contact", id: "gallery-field-placement-save")
    end
  end
end

Long content

Customer-provided labels and detailed guidance wrap without changing the component API.

Detailed configuration

Nitro Kit sends deployment, access, and billing events to this HTTPS endpoint. Changing it affects every administrator in the workspace.
Viewport640 px · sm
Rubytest/dummy/app/components/gallery/components/field_page.rb
render NitroKit::Field.new(
  nil,
  :webhook_url,
  as: :url,
  id: "gallery-field-long-content",
  value: "https://integrations.example.test/nitro/events/production-workspace",
  label: "Production workspace webhook destination",
  description: "Nitro Kit sends deployment, access, and billing events to this HTTPS endpoint. " \
    "Changing it affects every administrator in the workspace.",
  required: true,
  html: { id: "gallery-field-long-content-wrapper" }
)

Component contract

Constructor options, rendered root, closed vocabularies, and compound boundary for this component, exactly as shipped.

docs/component_contracts.md · NitroKit::Field

Constructor-specific options
  • optional Rails form builder and field name
  • see the full signature below
Root and closed vocabulary
div[data-nk=field][data-field-type=…]; types listed below
Contract
Default rendering owns label, description, control, and errors. A render block replaces the default composition. label, description, control, and errors remain available to custom compositions. The error list keeps native list semantics and uses aria-live=assertive; controls reference it through aria-describedby. Derived labels use human_attribute_name when the form object supplies one. as: :radio_group requires a legend and rejects label: false, falling back to I18n.t("nitro_kit.field.options_legend") when neither an explicit nor a derived label exists. as: :combobox binds the field label to #{id}-input through for and aria-labelledby and wires description, error, and invalid state onto the combobox input.

Relevant patterns

Application conventions this component belongs to. Each summary is the leading section of its pattern document.

docs/patterns/resource_form.md

Resource form

  • One model-backed Phlex component renders initial and invalid states.
  • Rails owns names, values, and errors; Nitro owns presentation.
  • Invalid mutations render the same model with 422; success redirects with 303.
  • Use one primary submit: the shell toolbar owns it, or a standalone form keeps it inside form.group.
  • Wrap the form in a Turbo Frame only when it needs an independent lifecycle.

System rules for coding agents

Instructions for coding agents, repeated on every component page so one fetched page has enough context. Humans can usually skip this section.

test/dummy/app/components/gallery/agent_rules.rb

View agent instructions
  • Nitro Kit 2.0 is a gem-owned, Phlex-only UI system for Rails. Render components directly: render NitroKit::Button.new("Save", variant: :primary).
  • Compose Nitro components inside application-owned Phlex classes. Public initializers and declared slots are the component API; private methods are not.
  • Public options are explicit keywords, and enumerated options are closed vocabularies. Invalid names or values raise ArgumentError; this component's accepted options are in the contract above.
  • Pass native attributes through their typed boundary: html: for HTML, aria: for ARIA, and data: for application data. class and style are forbidden, including inside html:.
  • Nitro owns NitroKit::Component::RESERVED_DATA_ATTRIBUTES: data-nk, data-slot, data-variant, data-size, data-nk-escape, data-enhanced, data-state, data-disabled, data-required, data-orientation, data-presentation, data-placement, data-layout, data-side, data-field-type, data-dir, data-gap, data-align, data-justify, data-wrap, data-cols, data-mode, data-key. Do not pass them through data:. data-action, data-controller are additive and compose with Nitro behavior.
  • If an integration truly requires a class, use desperately_need_a_class:. It requires a non-blank String and marks the exception with data-nk-escape="class".
  • Every root emits data-nk; owned parts emit component-qualified data-slot values such as field-control or card-title. Select on those attributes, never on classes.
  • Customize components with documented --nk-* custom properties in an application stylesheet. Variables beginning with --_nk-* are private component mechanics.
  • Use NitroKit::Flex and NitroKit::Grid for layout. Parents own external placement and available width; components own their intrinsic geometry.
  • Preserve native elements and accessibility semantics. State is exposed through native semantics and ARIA first, and through data-state when styling or behavior also needs it.