UNPKG

5.39 kBTypeScriptView Raw
1import * as React from 'react';
2import { Animated, ColorValue, GestureResponderEvent, PressableAndroidRippleConfig, StyleProp, TextStyle, ViewStyle } from 'react-native';
3import type { $Omit, EllipsizeProp, ThemeProp } from '../../types';
4import type { IconSource } from '../Icon';
5import Surface from '../Surface';
6export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
7 /**
8 * Mode of the chip.
9 * - `flat` - flat chip without outline.
10 * - `outlined` - chip with an outline.
11 */
12 mode?: 'flat' | 'outlined';
13 /**
14 * Text content of the `Chip`.
15 */
16 children: React.ReactNode;
17 /**
18 * Icon to display for the `Chip`. Both icon and avatar cannot be specified.
19 */
20 icon?: IconSource;
21 /**
22 * Avatar to display for the `Chip`. Both icon and avatar cannot be specified.
23 */
24 avatar?: React.ReactNode;
25 /**
26 * Icon to display as the close button for the `Chip`. The icon appears only when the onClose prop is specified.
27 */
28 closeIcon?: IconSource;
29 /**
30 * Whether chip is selected.
31 */
32 selected?: boolean;
33 /**
34 * Whether to style the chip color as selected.
35 * Note: With theme version 3 `selectedColor` doesn't apply to the `icon`.
36 * If you want specify custom color for the `icon`, render your own `Icon` component.
37 */
38 selectedColor?: string;
39 /**
40 * @supported Available in v5.x with theme version 3
41 * Whether to display overlay on selected chip
42 */
43 showSelectedOverlay?: boolean;
44 /**
45 * Whether to display default check icon on selected chip.
46 * Note: Check will not be shown if `icon` is specified. If specified, `icon` will be shown regardless of `selected`.
47 */
48 showSelectedCheck?: boolean;
49 /**
50 * Color of the ripple effect.
51 */
52 rippleColor?: ColorValue;
53 /**
54 * Whether the chip is disabled. A disabled chip is greyed out and `onPress` is not called on touch.
55 */
56 disabled?: boolean;
57 /**
58 * Type of background drawabale to display the feedback (Android).
59 * https://reactnative.dev/docs/pressable#rippleconfig
60 */
61 background?: PressableAndroidRippleConfig;
62 /**
63 * Accessibility label for the chip. This is read by the screen reader when the user taps the chip.
64 */
65 accessibilityLabel?: string;
66 /**
67 * Accessibility label for the close icon. This is read by the screen reader when the user taps the close icon.
68 */
69 closeIconAccessibilityLabel?: string;
70 /**
71 * Function to execute on press.
72 */
73 onPress?: (e: GestureResponderEvent) => void;
74 /**
75 * Function to execute on long press.
76 */
77 onLongPress?: () => void;
78 /**
79 * Function to execute as soon as the touchable element is pressed and invoked even before onPress.
80 */
81 onPressIn?: (e: GestureResponderEvent) => void;
82 /**
83 * Function to execute as soon as the touch is released even before onPress.
84 */
85 onPressOut?: (e: GestureResponderEvent) => void;
86 /**
87 * Function to execute on close button press. The close button appears only when this prop is specified.
88 */
89 onClose?: () => void;
90 /**
91 * The number of milliseconds a user must touch the element before executing `onLongPress`.
92 */
93 delayLongPress?: number;
94 /**
95 * @supported Available in v5.x with theme version 3
96 * Sets smaller horizontal paddings `12dp` around label, when there is only label.
97 */
98 compact?: boolean;
99 /**
100 * @supported Available in v5.x with theme version 3
101 * Whether chip should have the elevation.
102 */
103 elevated?: boolean;
104 /**
105 * Style of chip's text
106 */
107 textStyle?: StyleProp<TextStyle>;
108 style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
109 /**
110 * @optional
111 */
112 theme?: ThemeProp;
113 /**
114 * Pass down testID from chip props to touchable for Detox tests.
115 */
116 testID?: string;
117 /**
118 * Ellipsize Mode for the children text
119 */
120 ellipsizeMode?: EllipsizeProp;
121 /**
122 * Specifies the largest possible scale a text font can reach.
123 */
124 maxFontSizeMultiplier?: number;
125};
126/**
127 * Chips are compact elements that can represent inputs, attributes, or actions.
128 * They can have an icon or avatar on the left, and a close button icon on the right.
129 * They are typically used to:
130 * <ul>
131 * <li>Present multiple options </li>
132 * <li>Represent attributes active or chosen </li>
133 * <li>Present filter options </li>
134 * <li>Trigger actions related to primary content </li>
135 * </ul>
136 *
137 * ## Usage
138 * ```js
139 * import * as React from 'react';
140 * import { Chip } from 'react-native-paper';
141 *
142 * const MyComponent = () => (
143 * <Chip icon="information" onPress={() => console.log('Pressed')}>Example Chip</Chip>
144 * );
145 *
146 * export default MyComponent;
147 * ```
148 */
149declare const Chip: ({ mode, children, icon, avatar, selected, disabled, background, accessibilityLabel, accessibilityRole, closeIconAccessibilityLabel, onPress, onLongPress, onPressOut, onPressIn, delayLongPress, onClose, closeIcon, textStyle, style, theme: themeOverrides, testID, selectedColor, rippleColor: customRippleColor, showSelectedOverlay, showSelectedCheck, ellipsizeMode, compact, elevated, maxFontSizeMultiplier, ...rest }: Props) => React.JSX.Element;
150export default Chip;
151//# sourceMappingURL=Chip.d.ts.map
\No newline at end of file