Expand description
Ready-made UI components for Next Rust.
use next_rust_ui::*;
use next_rust_view::*;
let form = form![
Input![label = "Email", name = "email", kind = "email", placeholder = "you@example.com"],
PasswordInput![label = "Password", name = "password"],
Button![color = Color::Primary, submit = true, class("w-full"), "Sign in"],
];
let html = render_static(form);
assert!(html.contains(r#"class="nr-btn nr-btn-solid nr-c-primary nr-btn-md w-full""#));Every component is a builder with a macro of the same name. Inside the
macro, key = value sets a property and anything else is added like in an
element macro: attributes (class(..), id(..), aria(..), data(..))
and children. Every property is optional.
Styling:
- Each component has default classes (
nr-btn,nr-input, …) whose rules live in the CSScomponentslayer. Classes you add, Tailwind utilities or your own CSS, always win over them, without!important. unstyled = truedrops the default classes of the outer element.- Colors, radii and shadows are CSS variables (
--nr-primary,--nr-radius-md, …): set them on:rootto theme every component. Dark mode follows the system, orclass="dark"/data-theme="dark"on an ancestor. - Pages receive only the CSS of the components they render.
Interactive components (select, date picker, password toggle, tabs with
panels, modals, closable alerts, on_press) load a small script,
/_next-rust/ui.js, on the pages that use them. Without it they fall
back to the native control (a <select>, a <dialog>, <details>), so
pages keep working.
Macros§
- Accordion
- Build a
Accordion:key = valuesets a property, anything else is added as an attribute or child. - Accordion
Item - Build a
AccordionItem:key = valuesets a property, anything else is added as an attribute or child. - Alert
- Build a
Alert:key = valuesets a property, anything else is added as an attribute or child. - AppShell
- Build a
AppShell:key = valuesets a property, anything else is added as an attribute or child. - Avatar
- Build a
Avatar:key = valuesets a property, anything else is added as an attribute or child. - Avatar
Group - Build a
AvatarGroup:key = valuesets a property, anything else is added as an attribute or child. - Badge
- Build a
Badge:key = valuesets a property, anything else is added as an attribute or child. - Breadcrumb
Item - Build a
BreadcrumbItem:key = valuesets a property, anything else is added as an attribute or child. - Breadcrumbs
- Build a
Breadcrumbs:key = valuesets a property, anything else is added as an attribute or child. - Button
- Build a
Button:key = valuesets a property, anything else is added as an attribute or child. - Button
Group - Build a
ButtonGroup:key = valuesets a property, anything else is added as an attribute or child. - Card
- Build a
Card:key = valuesets a property, anything else is added as an attribute or child. - Card
Body - Build a
CardBody:key = valuesets a property, anything else is added as an attribute or child. - Card
Footer - Build a
CardFooter:key = valuesets a property, anything else is added as an attribute or child. - Card
Header - Build a
CardHeader:key = valuesets a property, anything else is added as an attribute or child. - Checkbox
- Build a
Checkbox:key = valuesets a property, anything else is added as an attribute or child. - Chip
- Build a
Chip:key = valuesets a property, anything else is added as an attribute or child. - Circular
Progress - Build a
CircularProgress:key = valuesets a property, anything else is added as an attribute or child. - Container
- Build a
Container:key = valuesets a property, anything else is added as an attribute or child. - Date
Picker - Build a
DatePicker:key = valuesets a property, anything else is added as an attribute or child. - Divider
- Build a
Divider:key = valuesets a property, anything else is added as an attribute or child. - Empty
State - Build a
EmptyState:key = valuesets a property, anything else is added as an attribute or child. - Grid
- Build a
Grid:key = valuesets a property, anything else is added as an attribute or child. - Input
- Build a
Input:key = valuesets a property, anything else is added as an attribute or child. - Kbd
- Build a
Kbd:key = valuesets a property, anything else is added as an attribute or child. - Modal
- Build a
Modal:key = valuesets a property, anything else is added as an attribute or child. - Modal
Body - Build a
ModalBody:key = valuesets a property, anything else is added as an attribute or child. - Modal
Footer - Build a
ModalFooter:key = valuesets a property, anything else is added as an attribute or child. - Navbar
- Build a
Navbar:key = valuesets a property, anything else is added as an attribute or child. - Navbar
Item - Build a
NavbarItem:key = valuesets a property, anything else is added as an attribute or child. - Password
Input - Build a
PasswordInput:key = valuesets a property, anything else is added as an attribute or child. - Progress
- Build a
Progress:key = valuesets a property, anything else is added as an attribute or child. - Radio
- Build a
Radio:key = valuesets a property, anything else is added as an attribute or child. - Radio
Group - Build a
RadioGroup:key = valuesets a property, anything else is added as an attribute or child. - Select
- Build a
Select:key = valuesets a property, anything else is added as an attribute or child. - Select
Item - Build a
SelectItem:key = valuesets a property, anything else is added as an attribute or child. - Sidebar
- Build a
Sidebar:key = valuesets a property, anything else is added as an attribute or child. - Sidebar
Item - Build a
SidebarItem:key = valuesets a property, anything else is added as an attribute or child. - Skeleton
- Build a
Skeleton:key = valuesets a property, anything else is added as an attribute or child. - Spinner
- Build a
Spinner:key = valuesets a property, anything else is added as an attribute or child. - Stack
- Build a
Stack:key = valuesets a property, anything else is added as an attribute or child. - Stat
- Build a
Stat:key = valuesets a property, anything else is added as an attribute or child. - Step
- Build a
Step:key = valuesets a property, anything else is added as an attribute or child. - Steps
- Build a
Steps:key = valuesets a property, anything else is added as an attribute or child. - Switch
- Build a
Switch:key = valuesets a property, anything else is added as an attribute or child. - Tab
- Build a
Tab:key = valuesets a property, anything else is added as an attribute or child. - Table
- Build a
Table:key = valuesets a property, anything else is added as an attribute or child. - Tabs
- Build a
Tabs:key = valuesets a property, anything else is added as an attribute or child. - Textarea
- Build a
Textarea:key = valuesets a property, anything else is added as an attribute or child. - Tooltip
- Build a
Tooltip:key = valuesets a property, anything else is added as an attribute or child.
Structs§
- Accordion
- Sections that expand one at a time (or several, with
multiple). - Accordion
Item - One section of an
Accordion: a<details>element, so it opens and closes without any script. - Alert
- A message that stands out: information, a success, a warning, an error.
- AppShell
- A full page layout: navbar on top, sidebar on the left (a drawer on small
screens, opened by the navbar’s
menu_toggle), content in the middle. - Avatar
- A user picture. Without
src, or when the image fails to load, it shows the initials ofname. - Avatar
Group - Overlapping avatars, with a
+Ncount pastmax. - Badge
- A count or a dot pinned to a corner of its child (an icon, an avatar).
- Breadcrumb
Item - One crumb; the last one is the current page.
- Breadcrumbs
- The path to the current page.
- Button
- A button, or a link styled as one (
href). - Button
Group - Buttons joined into one control.
- Card
- A surface grouping related content, with optional header and footer.
- Card
Body - The main content of a
Card. - Card
Footer - The bottom of a
Card, typically actions. - Card
Header - The top of a
Card. - Checkbox
- A checkbox with a label.
- Chip
- A small label: a tag, a status, a count.
- Circular
Progress - A ring that fills up.
- Container
- Centered content with a maximum width and side padding.
- Date
Picker - A date field with a calendar: month and year views, keyboard navigation,
minimum and maximum dates. The value is an ISO date (
2026-09-18); it is shown in the visitor’s locale. - Divider
- A thin line between content.
- Empty
State - What to show when there is nothing to show yet.
- Grid
- A responsive grid:
colscolumns on wide screens, fewer on narrow ones. Withmin_width, as many columns as fit. - Input
- A text input.
- Kbd
- A keyboard key:
Kbd!["⌘", "K"]renders two keys. - Modal
- A dialog over the page: a
<dialog>element. - Modal
Body - The content of a
Modal. - Modal
Footer - The bottom of a
Modal, typically its actions. - Navbar
- A top bar: brand on the left, links in the middle, actions on the right.
- Navbar
Item - A navbar link, highlighted on its page.
- Password
Input - A password input with a button that shows and hides the password.
- Press
- Behavior for
on_press: call a server action, navigate, dispatch an event, or run a script. - Progress
- A horizontal progress bar.
- Radio
- One choice of a
RadioGroup. - Radio
Group - Radio buttons sharing a name, with a label, description and error.
- Select
- A select with a styled listbox: keyboard navigation, type-ahead, single or
multiple choice. Submits like a native
<select>(it is one underneath). - Select
Item - One option of a
Select. The text children are its label. - Sidebar
- A vertical navigation list.
- Sidebar
Item - A sidebar link with an optional icon, highlighted on its page.
- Skeleton
- A placeholder that shimmers while the real content loads.
- Spinner
- A loading indicator.
- Stack
- Children in a column (or a row) with even spacing.
- Stat
- A number with its label: “Students · 1,204 · ↑ 12%”.
- Step
- One step of a process. Children are extra content under the description.
- Steps
- Where someone is in a process.
- Switch
- An on/off switch.
- Tab
- One tab. With
hrefit is a link (the page decides which is selected, byselectedor by matching the current path with the client runtime); with children it is a panel the component script switches to. - Table
- A data table.
columnsbecome the header; the children are the rows (tr![td![..], ..]), placed in the body. Wide tables scroll sideways inside their box instead of breaking the page. - Tabs
- A strip of tabs: links between pages, or panels switched in place.
- Textarea
- A multi-line text input that grows with its content.
- Tooltip
- A short text shown on hover or focus. CSS only: the anchor is the child, which should be focusable (a button, a link) so keyboard users see it too.
Enums§
- Accordion
Variant - Look of an
Accordion. - Align
- Cross-axis alignment of a
Stack. - Color
- Color of a component.
- Field
Variant - Visual style of text fields, selects and date pickers.
- Justify
- Main-axis distribution of a
Stack. - Label
Placement - Where a field’s label goes.
- Modal
Placement - Where a
Modalsits on the screen. - Placement
- Where a
Badgesits on its child. - Radius
- Corner rounding.
Nonein a builder keeps the component’s own default. - Shadow
- Shadow depth.
- Side
- Side of the anchor a
Tooltipshows on. - Size
- Size of a component.
- Step
Status - State of a
Step. - Tabs
Variant - Look of a
Tabsstrip. - Trend
- Direction of a
Stat’s change. - Variant
- Visual style of buttons and chips.
- Width
- Maximum width of a
Container.
Constants§
Statics§
- UI_CSS
- The component stylesheet. Components add it to the page themselves; only the rules for the components a page renders are sent.
Traits§
- Maybe
Text - Text that may be absent:
&str,Stringor anOptionof either, soerror_message = form.error("email")works as is.
Functions§
- rename_
script_ classes scriptwith everynr-*class name replaced throughrename, for release builds that give the component classes short names. A class name is a wholenr-…token (sodata-nr-uiis left alone).