Effects
Radius, elevation, motion, and the shared disabled treatment.
- Source
src/stylesheets/nitro_kit/tokens.css- API
var(--nk-radius-{step}), var(--nk-shadow-{step}), var(--nk-duration-{speed}), var(--nk-ease)
Radius
Five sizes and a circle. Radii move together when a theme changes shape, and --nk-button-radius separates button shape when a pill treatment should not recolor inputs and surfaces.
Every radius step
--nk-radius-xsTypeset code--nk-radius-smCheckbox--nk-radius-mdInput, Select, Dropdown, Badge--nk-radius-lgButton, Card, Alert, Toast--nk-radius-xlDialog, extra-large Button--nk-radius-fullAvatar, Switch, RadioButtonViewport
Ruby
test/dummy/app/components/gallery/foundations/effects_page.rbRADIUS_STEPS.each do |step, tier, consumers|
figure(data: { gallery: "depth" }) do
span(
aria: { hidden: true },
style: "--gallery-radius: var(--nk-radius-#{step})",
data: { gallery: "radius-chip" }
)
figcaption do
strong { tier }
code { "--nk-radius-#{step}" }
small { consumers }
end
end
endElevation
Four shadow steps form the depth ladder. Every surface sits on one rung.
Every shadow step
--nk-shadow-xsButton--nk-shadow-smCard, Tooltip--nk-shadow-mdDropdown, Combobox, Toast--nk-shadow-lgDialog, CommandPalette, SheetViewport
Ruby
test/dummy/app/components/gallery/foundations/effects_page.rbELEVATION_STEPS.each do |step, tier, consumers|
figure(data: { gallery: "depth" }) do
span(
aria: { hidden: true },
style: "--gallery-shadow: var(--nk-shadow-#{step})",
data: { gallery: "depth-chip" }
)
figcaption do
strong { tier }
code { "--nk-shadow-#{step}" }
small { consumers }
end
end
endMotion
Three durations and one deliberate easing curve, interruptible in both directions. Every transition stands down under prefers-reduced-motion, including these demos.
Every duration step
--nk-duration-fastAccordion chevron, tab highlight--nk-duration-normalControls, overlays, toasts--nk-duration-slowSheet, app shell drawercubic-bezier(0.4, 0, 0.2, 1)--nk-easeEnter and exit stay reversibleViewport
Ruby
test/dummy/app/components/gallery/foundations/effects_page.rbDURATION_STEPS.each do |speed, tier, consumers|
figure(data: { gallery: "depth" }) do
span(aria: { hidden: true }, style: "--gallery-duration: var(--nk-duration-#{speed})", data: { gallery: "motion-chip" }) do
span(data: { gallery: "motion-chip-handle" })
end
figcaption do
strong { tier }
code { "--nk-duration-#{speed}" }
small { consumers }
end
end
end
figure(data: { gallery: "depth" }) do
span(aria: { hidden: true }, data: { gallery: "motion-ease" }) { code { "cubic-bezier(0.4, 0, 0.2, 1)" } }
figcaption do
strong { "One curve, both directions" }
code { "--nk-ease" }
small { "Enter and exit stay reversible" }
end
endDisabled state
One opacity covers every disabled control.
Enabled and disabled
- API
var(--nk-disabled-opacity)
Viewport
Ruby
test/dummy/app/components/gallery/foundations/effects_page.rbrender NitroKit::Button.new("Save changes", id: "gallery-foundation-enabled")
render NitroKit::Button.new("Save changes", id: "gallery-foundation-disabled", disabled: true)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, 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.