Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/components/Searchbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ export type Props = Omit<TextInputProps, 'style'> & {
* TestID used for testing purposes
*/
testID?: string;
/**
* NativeWind class name. Applied to the outer surface and the text input.
*/
className?: string;
/**
* @optional
*/
Expand Down Expand Up @@ -199,6 +203,7 @@ const Searchbar = ({
value,
loading = false,
testID,
className,
ref,
...rest
}: Props) => {
Expand Down Expand Up @@ -252,6 +257,7 @@ const Searchbar = ({
style={[styles.container, style]}
elevation={elevation}
theme={theme}
{...(className != null ? { className } : null)}
>
<IconButton
role="button"
Expand Down Expand Up @@ -296,6 +302,7 @@ const Searchbar = ({
value={value}
testID={testID}
{...rest}
{...(className != null ? { className } : null)}
/>
{loading ? (
<ActivityIndicator style={styles.v3Loader} />
Expand Down
4 changes: 4 additions & 0 deletions src/components/Surface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ export type Props = Omit<ViewProps, 'pointerEvents' | 'style'> &
* TestID used for testing purposes
*/
testID?: string;
/**
* NativeWind class name forwarded to the underlying view.
*/
className?: string;
ref?: React.Ref<React.ComponentRef<typeof View>>;
};

Expand Down
11 changes: 11 additions & 0 deletions src/components/__tests__/Searchbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,14 @@ it('names its search icon as an image on web when it has no onIconPress', async
jest.restoreAllMocks();
}
});

it('applies className on the searchbar surface as well', async () => {
await render(
<Searchbar placeholder="Search" value="" className="bg-red-500" />
);

const input = screen.getByPlaceholderText('Search');

expect(input).toHaveProp('className', 'bg-red-500');
expect(input.parent).toHaveProp('className', 'bg-red-500');
});
Loading