Skip to main content

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​

VariantUse case
assistSmart or automated actions
filterFilter content, toggle on/off
inputInformation that the user entered, such as tags
suggestionDynamic 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​

PropTypeDefaultRequiredDescription
variantenum-No-
elevatedanyfalse false falseNoWhether the chip uses an elevated surface instead of an outline border.
leadingIconIconSource-NoIcon 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.
childrenstring-YesText label rendered inside the chip, on one line. A label that does not fit ends with an ellipsis.
onPressPressableProps-NoCalled 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.
iconSizenumber18NoSize of the leading icon in dp.
containerColorstring-NoOverride the container (background) color. State-layer colors (hover, press) are derived automatically.
contentColorstring-NoOverride the content (label and icon) color. State-layer colors are derived automatically when no containerColor is set.
labelStyleStyleProp<TextStyle>-NoAdditional style applied to the label text.
closeAccessibilityLabelstring`Remove ${children}`NoAccessible 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.
styleStyleProp<ViewStyle>-NoStyle 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.
selectedany-NoWhether the chip is selected (toggled on). Pair with `onSelectedChange`, or use `defaultSelected` for an uncontrolled filter chip.
defaultSelectedany-NoInitial selection for an uncontrolled filter chip. The chip flips its own state on press and reports it through `onSelectedChange`.
onSelectedChangeany-NoCalled with the next state when a filter chip is pressed.
onCloseany-NoCallback 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.
avatarany-NoCustom avatar content (e.g. a small Image or View) before the label.