We are excited to announce the latest update to NextUI, version 2.2.0! This release introduces 3 new components, support for client-side routing, and more.
Sandpack demo
What's New in v2.2.0?
- Client Side Routing - Allows you to seamlessly incorporate client-side routers.
- Autocomplete - Combines a text input with a listbox, allowing users to filter a list of options.
- Slider - Allows users to make selections from a range of values.
- Breadcrumbs - Displays a hierarchy of links to the current page or resource in an application.
- Other Changes - Includes styling improvements, accessibility and usability enhancements.
Client Side Routing
By default, links perform native browser navigation when they are interacted with. However, many apps and frameworks use client side routers to avoid a full page reload when navigating between pages.
NextUI now natively supports client-side routing in components such as Link, Tabs, Breadcrumbs, Listbox, Dropdown and many others offering the flexibility to be rendered as HTML links, allowing you to seamlessly incorporate client-side routers. See the Routing guide to learn how it set it up in your app.
The NextUIProvider component configures all NextUI components within it to navigate using the
client side router you provide.
Note: Client side routing is based on React Aria Routing.
Next.js Example
-
App Router
Go to your
app/providers.tsxorapp/providers.jsx(create it if it doesn't exist) and add theuseRouterhook fromnext/navigation, it returns a router object that can be used to perform navigation.app/providers.tsx
1"use client";23import { NextUIProvider } from "@nextui-org/react";45export function Providers({ children }: { children: React.ReactNode }) {6 const router = useRouter();78 return <NextUIProvider navigate={router.push}>{children}</NextUIProvider>;9} -
Pages Router
Go to pages
/_app.jsorpages/_app.tsx(create it if it doesn't exist) and add theuseRouterhook fromnext/router, it returns a router object that can be used to perform navigation.1// pages/_app.tsx2import type { AppProps } from "next/app";3import { useRouter } from "next/router";4import { NextUIProvider } from "@nextui-org/react";56function MyApp({ Component, pageProps }: AppProps) {7 const router = useRouter();89 return (10 <NextUIProvider navigate={router.push}>11 <Component {...pageProps} />12 </NextUIProvider>13 );14}1516export default MyApp; -
Usage
Now that you have set up the
NextUIProviderin your app, you can use thehrefprop in theTabs,ListboxandDropdownitems to navigate between pages.The Link component will also use the
navigatefunction from theNextUIProviderto navigate between pages.1import {2 Tabs,3 Tab,4 Listbox,5 ListboxItem,6 Dropdown,7 DropdownTrigger,8 DropdownMenu,9 DropdownItem,10 Button,11 Link,12} from "@nextui-org/react";1314function App() {15 return (16 <>17 <Tabs aria-label="Navigation">18 <Tab key="home" href="/home">19 Home20 </Tab>21 <Tab key="about" href="/about">22 About23 </Tab>24 </Tabs>25 <Listbox aria-label="Navigation">26 <ListboxItem key="home" href="/home">27 Home28 </ListboxItem>29 <ListboxItem key="about" href="/about">30 About31 </ListboxItem>32 </Listbox>33 <Dropdown>34 <DropdownTrigger>35 <Button>Open</Button>36 </DropdownTrigger>37 <DropdownMenu aria-label="Navigation">38 <DropdownItem key="home" href="/home">39 Home40 </DropdownItem>41 <DropdownItem key="about" href="/about">42 About43 </DropdownItem>44 </DropdownMenu>45 </Dropdown>46 <Link href="/home">Home</Link>47 <Link href="/about">About</Link>48 </>49 );50}
Autocomplete
Creating an autocomplete component that is both accessible and customizable is a challenging task. We've spent a lot of time researching and testing different approaches to come up with a solution that works for everyone. The result is a component that is easy to use, fully accessible, and highly customizable.
The new Autocomplete component includes:
- Support for selecting a single option.
- Support for disabled options.
- Support for groups of items in sections.
- Support for filtering a list of options by typing.
- Support for controlled and uncontrolled options, selection and input value.
- Support for custom filter functions.
- Async loading and infinite scrolling support.
- Required and invalid states exposed to assistive technology via ARIA.
- Support for description and error message help text linked to the input via ARIA.
- And much more...
We recommend to read this Blog post from react-aria team to learn more about the Autocomplete component.