Skip to content

Material 3

Get started

React Aria

Use React Aria props, parts and providers with the components.

Use the components the way you use React Aria Components: with the same props, parts and providers. This page covers what the components have in common, and each component's page covers its own props.

Component props

Pass React Aria's props to a component next to its Material 3 ones:

<Button variant="tonal" isDisabled={!canSave} onPress={save}>
  Save
</Button>

These props work the same way across components:

PropUse
className, styleA value, or a function of the component's state, such as isHovered, isPressed, isFocusVisible, isDisabled or isSelected. See Styling.
childrenThe content, or a function of the same state. See Composition.
slotThe place a component takes in its parent. See Composition.
onPressA press with a mouse, a touch, the keyboard or assistive technology, on a button or an item. Use it in place of onClick.
isDisabledDisables a control, in place of the disabled attribute.
renderA function that renders another element in the component's place, as React Aria's render prop does. On a button, use elementType instead.
refThe element that className is on. A TextField, a Checkbox, a Radio and a Switch also take inputRef, for their input.

A component's page lists its props. For how each one behaves, see the page of its React Aria component, such as Button, Menu or Calendar.

Imports

Import the components from @material-web/react, with the triggers DialogTrigger, SheetTrigger, TooltipTrigger and PreviewTrigger. Import the parts React Aria already provides from react-aria-components:

ImportUse
Text, Heading, Label, Keyboard, HeaderThe text of a component, each in its slot
MenuTrigger, SubmenuTrigger, MenuSection, SeparatorThe trigger, the sections and the dividers of a menu
Input, AutocompleteThe input of a search field, and the filtering of a list as the query is typed
Form, FieldErrorA form, and the error message of a field. See Forms.
RouterProvider, I18nProviderThe app's router and locale. See Routing and Internationalization.
Ada LovelaceMathematician
Alan TuringComputer scientist
import { Icon, IconButton, List, ListItem } from '@material-web/react'
import { Text } from 'react-aria-components'

export default function Slots() {
  return (
    <List aria-label="Contacts" variant="segmented" className="w-80">
      <ListItem id="ada" textValue="Ada Lovelace">
        <Icon slot="leading" name="person" />
        <Text slot="label">Ada Lovelace</Text>
        <Text slot="description">Mathematician</Text>
        <IconButton slot="trailing" aria-label="Call Ada Lovelace">
          <Icon name="call" />
        </IconButton>
      </ListItem>
      <ListItem id="alan" textValue="Alan Turing">
        <Icon slot="leading" name="person" />
        <Text slot="label">Alan Turing</Text>
        <Text slot="description">Computer scientist</Text>
        <IconButton slot="trailing" aria-label="Call Alan Turing">
          <Icon name="call" />
        </IconButton>
      </ListItem>
    </List>
  )
}
  • Hooks: React Aria's hooks work with the components, such as useFilter and useListData.
  • Dates: Pass a date or a time as an object from @internationalized/date, such as a CalendarDate or a Time.
  • Package managers: npm installs both packages with the library. With a package manager that keeps a project from importing the dependencies of its dependencies, such as pnpm, add them to your project as well.

Routing

To make an item a link, give it an href. To send these links through a client-side router, wrap the app in RouterProvider once:

import { RouterProvider } from 'react-aria-components'
import { useHref, useNavigate } from 'react-router'

function App() {
  const navigate = useNavigate()
  return (
    <RouterProvider navigate={navigate} useHref={useHref}>
      {/* ... */}
    </RouterProvider>
  )
}
ComponentLink
ListItem, MenuItem, FabMenuItem, TabSet href. The link goes through the router.
Button, IconButton, Fab, SplitButtonLeadingSet elementType="a" and href. It is a native link, which the browser follows without the router.
NavigationBarItem, NavigationRailItemTakes no href. Navigate in its onChange or onPress.

For the setup of each framework, see React Aria's Framework setup guide.

Forms

Give a field a name to include it in a form. It is submitted and reset with the form. To validate it, set isRequired or pass a validate function: an invalid field blocks its form from being submitted. See React Aria's Forms guide.

For what each field submits and how it shows an error, see its page: Text field, Checkbox, Radio button, Switch and Date field. To put a form in a dialog, see Dialog.

Internationalization

The locale is the browser's by default. To set another, wrap the app in an I18nProvider:

import { I18nProvider } from 'react-aria-components'

function Root() {
  return (
    <I18nProvider locale="ar-AE">
      <App />
    </I18nProvider>
  )
}
  • Direction: For a right-to-left language, set both the locale and the dir attribute. The arrow keys follow the locale, and the layout follows dir.
  • Dates: Dates and times are formatted for the locale, which also sets the calendar system and the first day of the week.
  • Built-in names: The few controls that React Aria names itself, such as the close button of a snackbar, are named in the locale's language. All other text is yours to write.
  • Server rendering: Set the locale explicitly on a server-rendered page, so that the server and the browser format dates alike.