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

Grid

Responsive one-to-twelve-column collections with Tailwind-style breakpoint shorthand.

Source
app/components/nitro_kit/grid.rb
API
NitroKit::Grid.new(cols: "1 sm:2 lg:3", gap: "2 md:4")

Mobile-first columns

Column and gap values use the same base, sm, md, lg, xl, and 2xl shorthand as Flex.

One to three cards

API
cols: "1 sm:2 lg:3", gap: "3 md:4 lg:6"

Starter

One workspace, Three members, and Community support

Team

Unlimited workspaces, Twenty members, and Email support

Business

Unlimited members, Audit log, and Priority support
ViewportFull width
Rubytest/dummy/app/components/gallery/components/grid_page.rb
render NitroKit::Container.new(size: :xl) do
  render NitroKit::Grid.new(
    cols: "1 sm:2 lg:3",
    gap: "3 md:4 lg:6",
    id: "gallery-grid-cards"
  ) do
    Gallery::Data.plans.each do |plan|
      render NitroKit::Card.new(id: "gallery-grid-card-#{plan.id}") do |card|
        card.title(plan.name, level: 4)
        card.body(plan.features.to_sentence)
        card.footer do
          render NitroKit::Button.new(
            plan.current ? "Manage" : "Choose",
            variant: plan.current ? :default : :primary
          )
        end
      end
    end
  end
end

Every breakpoint

Track 1Track 2Track 3Track 4Track 5Track 6Track 7Track 8Track 9Track 10Track 11Track 12
ViewportFull width
Rubytest/dummy/app/components/gallery/components/grid_page.rb
render NitroKit::Grid.new(
  cols: "1 sm:2 md:3 lg:4 xl:6 2xl:12",
  gap: "1 sm:2 md:3 lg:4 xl:6 2xl:8",
  id: "gallery-grid-breakpoints"
) do
  12.times do |index|
    render NitroKit::Badge.new(
      "Track #{index + 1}",
      id: "gallery-grid-breakpoint-#{index + 1}",
      variant: :outline
    )
  end
end

Scalar columns

A scalar keeps one column count at every viewport; the closed range is one through twelve.

Representative counts

1 column
1
2 columns
12
3 columns
123
4 columns
1234
6 columns
123456
12 columns
123456789101112
ViewportFull width
Rubytest/dummy/app/components/gallery/components/grid_page.rb
[ 1, 2, 3, 4, 6, 12 ].each do |cols|
  sample("#{cols} #{'column'.pluralize(cols)}", slug: "cols-#{cols}") do
    render NitroKit::Grid.new(cols:, gap: 1, id: "gallery-grid-cols-#{cols}") do
      cols.times do |index|
        render NitroKit::Badge.new(
          "#{index + 1}",
          id: "gallery-grid-cols-#{cols}-#{index + 1}",
          color: :info
        )
      end
    end
  end
end

Independent responsive decisions

Columns and spacing can change at different breakpoints without exposing arbitrary CSS values.

Two useful collection shapes

Catalog

Integration 1

A roomy card collection gains columns gradually.

Integration 2

A roomy card collection gains columns gradually.

Integration 3

A roomy card collection gains columns gradually.

Integration 4

A roomy card collection gains columns gradually.

Integration 5

A roomy card collection gains columns gradually.

Integration 6

A roomy card collection gains columns gradually.

Integration 7

A roomy card collection gains columns gradually.

Integration 8

A roomy card collection gains columns gradually.
Metrics

Region 1

128430 requests

Region 2

256860 requests

Region 3

385290 requests

Region 4

513720 requests

Region 5

642150 requests

Region 6

770580 requests

Region 7

899010 requests

Region 8

1027440 requests

Region 9

1155870 requests

Region 10

1284300 requests

Region 11

1412730 requests

Region 12

1541160 requests
ViewportFull width
Rubytest/dummy/app/components/gallery/components/grid_page.rb
sample("Catalog", slug: "catalog") do
  render NitroKit::Grid.new(
    cols: "1 md:2 xl:4",
    gap: "2 lg:6",
    id: "gallery-grid-catalog"
  ) do
    8.times do |index|
      render NitroKit::Card.new(id: "gallery-grid-catalog-#{index + 1}") do |card|
        card.title("Integration #{index + 1}", level: 4)
        card.body("A roomy card collection gains columns gradually.")
      end
    end
  end
end

sample("Metrics", slug: "metrics") do
  render NitroKit::Grid.new(
    cols: "2 lg:4 2xl:6",
    gap: "2 md:3",
    id: "gallery-grid-metrics"
  ) do
    12.times do |index|
      render NitroKit::Card.new(id: "gallery-grid-metric-#{index + 1}") do |card|
        card.title("Region #{index + 1}", level: 4)
        card.body("#{(index + 1) * 128_430} requests")
      end
    end
  end
end

Content pressure

Empty, partial, dense, and uneven collections retain the declared responsive contract.

Empty, one, and many

Empty
One
One item occupies one track; Grid does not invent a span API.
Many

Record 1

Deterministic collection item

Record 2

Deterministic collection item

Record 3

Deterministic collection item

Record 4

Deterministic collection item

Record 5

Deterministic collection item

Record 6

Deterministic collection item

Record 7

Deterministic collection item

Record 8

Deterministic collection item

Record 9

Deterministic collection item
ViewportFull width
Rubytest/dummy/app/components/gallery/components/grid_page.rb
sample("Empty", slug: "empty") do
  render NitroKit::Grid.new(cols: "1 md:3", gap: 4, id: "gallery-grid-empty")
end
sample("One", slug: "one") do
  render NitroKit::Grid.new(cols: "1 md:3", gap: 4, id: "gallery-grid-one") do
    render NitroKit::Card.new do |card|
      card.body("One item occupies one track; Grid does not invent a span API.")
    end
  end
end
sample("Many", slug: "many") do
  render NitroKit::Grid.new(cols: "1 sm:2 lg:3", gap: 2, id: "gallery-grid-many") do
    9.times do |index|
      render NitroKit::Card.new do |card|
        card.title("Record #{index + 1}", level: 4)
        card.body("Deterministic collection item")
      end
    end
  end
end

Uneven team records

Ada Lovelace

Active

[email protected]

International Research, Production, and Reliability Engineering

Grace Hopper

Active

[email protected]

Katherine Johnson

Invited

[email protected]

ViewportFull width
Rubytest/dummy/app/components/gallery/components/grid_page.rb
render NitroKit::Grid.new(
  cols: "1 sm:2 lg:3",
  gap: "3 lg:6",
  id: "gallery-grid-team"
) do
  Gallery::Data.members.each do |member|
    render NitroKit::Card.new(id: "gallery-grid-team-#{member.id}") do |card|
      card.title(member.name, level: 4)
      card.body do
        render NitroKit::Flex.new(dir: :col, gap: 2, align: :start) do
          render NitroKit::Badge.new(
            member.status.to_s.humanize,
            color: member.status == :active ? :success : :info
          )
          p { member.email }
          p { "International Research, Production, and Reliability Engineering" } if member == Gallery::Data.members.first
        end
      end
      card.footer do
        render NitroKit::Flex.new(dir: :row, gap: 1, align: :center, wrap: :wrap) do
          render NitroKit::Button.new("View", size: :sm)
          render NitroKit::Button.new("Change role", size: :sm)
        end
      end
    end
  end
end

Component contract

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

docs/component_contracts.md · NitroKit::Grid

Constructor
required cols:; gap: 4, id: nil
Root
div[data-nk=grid]
Contract
Columns and gap accept scalar or responsive values. Equal minmax(0, 1fr) tracks; direct content; empty content is valid.

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.