SearchField

A basic text input field used as search.

Example

import { SearchField } from "@styple/design-system";
// Boilerplate component of how to implement a searchbar with SearchField
export const Searchbar = () => {
const [query, setQuery] = useState("");
function keyPressed(e: React.KeyboardEvent) {
// Check and prevent default for 'Enter'
if (e.key === "Enter") {
e.preventDefault();
}
}
return (
<form style={{ width: "100%" }}>
<SearchField query={query} setQuery={setQuery} keyPressed={keyPressed} placeholder="Search test.." />
</form>
);
};

API Reference

SearchField

A styled component using TextField internally. Custom props:

Prop Type Default Explanation
querystring-

The current text string.

setQuerySetStateAction-

React state setter called onChange with target value.

keyPressedKeyboardEventHandler-

Keyboard event called onKeyPress with event.