React Native / Inputs
Chip
Compact filter, choice or tag. Selected chips are announced as selected.
import { Chip } from "@stylhero/native";
Example
import { useState } from "react";
import { Chip, Stack } from "@stylhero/native";
function ChipExample() {
const [games, setGames] = useState<string[]>(["Fortnite"]);
const toggle = (game: string) =>
setGames((g) => (g.includes(game) ? g.filter((x) => x !== game) : [...g, game]));
return (
<Stack direction="row" gap={2} wrap>
{["Fortnite", "Valorant", "Cyberpunk 2077"].map((game) => (
<Chip key={game} selectionRole="checkbox" selected={games.includes(game)} onPress={() => toggle(game)}>
{game}
</Chip>
))}
</Stack>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children required |
string |
- | |
disabled |
boolean |
- | |
icon |
ReactNode |
- | |
onPress |
() => void |
- | |
onRemove |
() => void |
- | Shows a remove button, e.g. for an applied filter or a tag. |
removeLabel |
string |
- | Spoken name of the remove button. Default "Remove <label>". |
selected |
boolean |
- | Makes it a filter chip that toggles: pass the current state and an onPress. |
selectionRole |
"checkbox" | "radio" |
- | How a selectable chip is announced. Default: a button that is "selected". "checkbox" for chips where several can be picked ("Fortnite, checkbox, checked"), "radio" for chips where only one can (budget presets). |
style |
StyleProp<ViewStyle> |
- | |
testID |
string |
- |
Screen reader gestures
| Gesture (VoiceOver / TalkBack) | Does |
|---|---|
| Double-tap | Selects or unselects it, or removes it with onRemove |
Accessibility
selectionRole="checkbox"for multi-select filters and"radio"for a single choice, so the chip says checked or selected. Without it, a pressable chip is a button.- The remove button is labelled "Remove …" (
removeLabel).
Generated from src/components/Chip.tsx. Something wrong or missing? Open an issue.