Chip
Chips help people enter information, make selections, filter content, or trigger actions. The component follows the Material Design 3 Chip specification.
Usage
import { Chip } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { Alert, View } from 'react-native'
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Chip variant="assist" onPress={() => Alert.alert('Pressed')}>
Assist
</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}
Variants
| Variant | Use case |
|---|---|
assist | Smart or automated actions |
filter | Filter content, toggle on/off |
input | Information that the user entered, such as tags |
suggestion | Dynamic suggestions |
Elevated
Available on the assist, filter, and suggestion variants. An input chip is always outlined, so elevated is not one of its props. TypeScript rejects <Chip variant="input" elevated>, and doesn't ignore it.
import { Chip } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Chip variant="assist" elevated onPress={() => {}}>Elevated Assist</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}
Filter Chips
A filter chip supports a selected state. When it is selected, the chip shows
a check mark icon. selected with onSelectedChange is the controlled
form. defaultSelected is the uncontrolled form: the chip flips its own state
on press and reports the new state through onSelectedChange.
import { Chip } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { useState } from 'react'
import { View } from 'react-native'
export default function App() {
const [active, setActive] = useState(true)
const [inactive, setInactive] = useState(false)
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8 }}>
<Chip variant="filter" selected={active} onSelectedChange={setActive}>Active</Chip>
<Chip variant="filter" selected={inactive} onSelectedChange={setInactive}>Inactive</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}
Close / Remove
Pass onClose to show a trailing close icon. It renders only on the input variant, and on the filter variant when the chip is selected.
The close icon is an accessibility target separate from the chip, so it names itself Remove {label}, not a bare "Remove". A screen-reader user hears which chip they are about to remove. Override the whole string with closeAccessibilityLabel when you localize.
import { Chip } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { Alert, View } from 'react-native'
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8 }}>
<Chip variant="input" onClose={() => Alert.alert('Closed')}>Tag</Chip>
<Chip variant="filter" selected onClose={() => Alert.alert('Closed')}>Active</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}
With Icons
import { Chip } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8 }}>
<Chip leadingIcon="calendar" onPress={() => {}}>Schedule</Chip>
<Chip variant="input" leadingIcon="tag" onClose={() => {}}>Tagged</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}
Avatar
The input variant supports a custom avatar prop. avatar and leadingIcon are mutually exclusive on this variant. TypeScript rejects both together.
import { Chip } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { Image, View } from 'react-native'
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Chip
variant="input"
avatar={
<Image
source={{ uri: 'https://i.pravatar.cc/40' }}
style={{ width: 24, height: 24, borderRadius: 12 }}
/>
}
onClose={() => {}}
>
John Doe
</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}
Disabled
import { Chip } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Chip disabled onPress={() => {}}>Disabled</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}
A chip with no action
A chip is a button only when a press does something. An assist, suggestion or
input chip with no onPress, no onLongPress and no href renders as a
static label. It has no button role, no tab stop, no hover layer and no
pointer cursor. A screen reader reads its text, and a keyboard user doesn't
stop on it. An input chip with only onClose keeps its close button.
<Chip leadingIcon="language-typescript">TypeScript-first</Chip>
A filter chip is always a button, because a press toggles it.
A chip inside the <Link asChild> of Expo Router stays a button with no onPress
of its own. Link gives it an href, and on the web the chip renders as an
<a href>.
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
variant | enum | - | No | - |
elevated | any | false
false
false | No | Whether the chip uses an elevated surface instead of an outline border. |
leadingIcon | IconSource | - | No | Icon rendered before the label. Accepts a string name (resolved via the theme's `iconResolver`, for example `mdiResolver`), a pre-rendered element, or a render function that receives `{ size, color }`. Icon rendered before the label. When the chip is selected and no `leadingIcon` is provided, a checkmark is shown automatically. Icon rendered before the label. |
children | string | - | Yes | Text label rendered inside the chip, on one line. A label that does not fit ends with an ellipsis. |
onPress | PressableProps | - | No | Called when the chip is pressed. With no `onPress`, `onLongPress` or `href`, an assist, suggestion or input chip is a static label: no button role and no tab stop. A filter chip is always a button, because a press toggles it. Expo Router's `<Link asChild>` passes `role="link"` and `href`, so the chip renders as an `<a>` on the web. |
iconSize | number | 18 | No | Size of the leading icon in dp. |
containerColor | string | - | No | Override the container (background) color. State-layer colors (hover, press) are derived automatically. |
contentColor | string | - | No | Override the content (label and icon) color. State-layer colors are derived automatically when no containerColor is set. |
labelStyle | StyleProp<TextStyle> | - | No | Additional style applied to the label text. |
closeAccessibilityLabel | string | `Remove ${children}` | No | Accessible label for the trailing close affordance, when one renders. The close button is a second target inside what looks like one control, so a bare "Remove" leaves a screen-reader user with no way to tell which chip they are on. Defaults to `` `Remove ${children}` `` — the chip's own label composed in — which is also why this is a prop: that default is English, and word order does not survive translation. |
style | StyleProp<ViewStyle> | - | No | Style for the component. The keys that place or size it in its parent — `alignSelf`, `flex`, `flexGrow`, `flexShrink`, `flexBasis`, `width`, the margins, `position`, the insets and `zIndex` — go to the outer wrapper, so the focus ring and the shadow move with it. `minWidth` and `maxWidth` go with a `width`; alone, they style the container. The wrapper sets no `alignSelf`, so the parent's `alignItems` places the component. In a parent that stretches its children, the component keeps its own width at the start edge. Every other key styles the container. Static form only — the function form `(state) => style` is not supported because the component drives its container background through Reanimated. Use `containerColor` / `contentColor` for state-aware styling. |
selected | any | - | No | Whether the chip is selected (toggled on). Pair with `onSelectedChange`, or use `defaultSelected` for an uncontrolled filter chip. |
defaultSelected | any | - | No | Initial selection for an uncontrolled filter chip. The chip flips its own state on press and reports it through `onSelectedChange`. |
onSelectedChange | any | - | No | Called with the next state when a filter chip is pressed. |
onClose | any | - | No | Callback fired when the close icon is pressed. The close icon only renders when the chip is selected. Callback fired when the close/remove icon is pressed. When provided, renders a trailing close icon. |
avatar | any | - | No | Custom avatar content (e.g. a small Image or View) before the label. |