Colors
Public color scales and shared tint roles for building and theming Nitro Kit interfaces.
- Source
src/stylesheets/nitro_kit/tokens.css- API
var(--nk-{family}-{step}) and var(--nk-palette-{color})
Poles
White and black anchor pure surfaces, foregrounds, and overlays and can be rethemed independently.
White and black
whiteblacktest/dummy/app/components/gallery/foundations/colors_page.rb%i[white black].each { |color| color_swatch(color, token: "--nk-#{color}") }Neutral scales
Cool through warm neutral ramps for canvas, surface, border, and content roles.
Neutral families
--nk-slate-{step}50100200300400500600700800900950--nk-gray-{step}50100200300400500600700800900950--nk-zinc-{step}50100200300400500600700800900950--nk-neutral-{step}50100200300400500600700800900950--nk-stone-{step}50100200300400500600700800900950test/dummy/app/components/gallery/foundations/colors_page.rbNEUTRAL_FAMILIES.each { |family| color_scale(family) }Color scales
Every public family includes all eleven appearance-independent steps. Use 50–200 for tints and surfaces, 400–600 for accents and markers, and 700–950 for content.
Color families
--nk-red-{step}50100200300400500600700800900950--nk-orange-{step}50100200300400500600700800900950--nk-amber-{step}50100200300400500600700800900950--nk-yellow-{step}50100200300400500600700800900950--nk-lime-{step}50100200300400500600700800900950--nk-green-{step}50100200300400500600700800900950--nk-emerald-{step}50100200300400500600700800900950--nk-teal-{step}50100200300400500600700800900950--nk-cyan-{step}50100200300400500600700800900950--nk-sky-{step}50100200300400500600700800900950--nk-blue-{step}50100200300400500600700800900950--nk-indigo-{step}50100200300400500600700800900950--nk-violet-{step}50100200300400500600700800900950--nk-purple-{step}50100200300400500600700800900950--nk-fuchsia-{step}50100200300400500600700800900950--nk-pink-{step}50100200300400500600700800900950--nk-rose-{step}50100200300400500600700800900950test/dummy/app/components/gallery/foundations/colors_page.rbCOLOR_FAMILIES.each { |family| color_scale(family) }Tint palette
Badge, Alert, and Toast share these semantic and decorative tint roles. Semantic names follow application meaning; hue names remain literal.
Palette roles
test/dummy/app/components/gallery/foundations/colors_page.rbNitroKit::Badge::COLORS.each do |color|
render NitroKit::Badge.new(
"--nk-palette-#{color}",
id: "gallery-color-palette-#{color}",
color:
)
endSystem 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, anddata:for application data.classandstyleare forbidden, including insidehtml:. - 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 throughdata:.data-action,data-controllerare 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 withdata-nk-escape="class". - Every root emits
data-nk; owned parts emit component-qualifieddata-slotvalues such asfield-controlorcard-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::FlexandNitroKit::Gridfor 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-statewhen styling or behavior also needs it.