diff --git a/src/components/Searchbar.tsx b/src/components/Searchbar.tsx index f1f6adbbfd..862ecf42a8 100644 --- a/src/components/Searchbar.tsx +++ b/src/components/Searchbar.tsx @@ -137,6 +137,10 @@ export type Props = Omit & { * TestID used for testing purposes */ testID?: string; + /** + * NativeWind class name. Applied to the outer surface and the text input. + */ + className?: string; /** * @optional */ @@ -199,6 +203,7 @@ const Searchbar = ({ value, loading = false, testID, + className, ref, ...rest }: Props) => { @@ -252,6 +257,7 @@ const Searchbar = ({ style={[styles.container, style]} elevation={elevation} theme={theme} + {...(className != null ? { className } : null)} > {loading ? ( diff --git a/src/components/Surface.tsx b/src/components/Surface.tsx index d1a4e07e99..6a6631ac9c 100644 --- a/src/components/Surface.tsx +++ b/src/components/Surface.tsx @@ -152,6 +152,10 @@ export type Props = Omit & * TestID used for testing purposes */ testID?: string; + /** + * NativeWind class name forwarded to the underlying view. + */ + className?: string; ref?: React.Ref>; }; diff --git a/src/components/__tests__/Searchbar.test.tsx b/src/components/__tests__/Searchbar.test.tsx index 268dfb27c8..59b96e30a7 100644 --- a/src/components/__tests__/Searchbar.test.tsx +++ b/src/components/__tests__/Searchbar.test.tsx @@ -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( + + ); + + const input = screen.getByPlaceholderText('Search'); + + expect(input).toHaveProp('className', 'bg-red-500'); + expect(input.parent).toHaveProp('className', 'bg-red-500'); +});