Skip to main content

Chip

Chips help people enter information, make selections, filter content, or trigger actions. Follows the Material Design 3 Chip specification.

Usage

import { Chip } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { Alert, View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<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
inputUser-entered info like tags
suggestionDynamic suggestions

Elevated

Available on assist, filter, and suggestion variants. Ignored on input.

import { Chip } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Chip variant="assist" elevated onPress={() => {}}>Elevated Assist</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}

Filter Chips

Filter chips support a selected state. When selected, a checkmark icon appears automatically.

import { Chip } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/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>
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8 }}>
<Chip variant="filter" selected={active} onPress={() => setActive(!active)}>Active</Chip>
<Chip variant="filter" selected={inactive} onPress={() => setInactive(!inactive)}>Inactive</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}

Close / Remove

Pass onClose to show a trailing close icon. Only renders on input and filter (when selected) variants.

import { Chip } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { Alert, View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<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 '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<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 will reject passing both.

import { Chip } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { Image, View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<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 '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Chip disabled onPress={() => {}}>Disabled</Chip>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}

Props

PropTypeDefaultRequiredDescription
variantenum-No-
elevatedbooleanfalse 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`, defaulting to `MaterialCommunityIcons`), 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.
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.
styleStyleProp<ViewStyle>-NoStyle applied to the root 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.
onKeyDown(event: { nativeEvent: { key?: string; }; }) => void-No-
selectedboolean-NoWhether the chip is in a selected (toggled-on) state.
onClose(() => void) | (() => void)-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.
avatarReactNode-NoCustom avatar content (e.g. a small Image or View) before the label.