Skip to content

Theme

Filter Sphere provides a set of themes that allowing you to tailor them to your specific preferences or project needs.

Furthermore, you have the option to create your own theme based on the default ones.

The Material UI theme offers a clean and straightforward appearance, leveraging MUI Material UI.

Terminal window
pnpm add @fn-sphere/theme-mui-material
// 1. Import the MUI Material theme
import { filterTheme } from "@fn-sphere/theme-mui-material";
import {
FilterSphereProvider,
FilterBuilder,
useFilterSphere,
} from "@fn-sphere/filter";
export default function AdvancedFilter({ schema }) {
const { predicate, context } = useFilterSphere({ schema });
return (
// 2. Set the theme for the Filter Sphere
<FilterSphereProvider context={context} theme={filterTheme}>
<FilterBuilder />
</FilterSphereProvider>
);
}

You can override existing theme by replacing them with your own custom components or templates.

WHERE

WHERE

You can modify a component by overriding the specific component in the theme.

import {
FilterSphereProvider,
FilterBuilder,
useFilterSphere,
useFilterRule,
createFilterTheme,
} from "@fn-sphere/filter";
import { z } from "zod";
const schema = z.object({
id: z.number(),
name: z.string(),
});
const customTheme = createFilterTheme({
components: {
Button: (props) => <button style={{ borderRadius: "10px" }} {...props} />,
},
});
export default function AdvancedFilter() {
const { predicate, context } = useFilterSphere({ schema });
return (
<FilterSphereProvider context={context} theme={customTheme}>
<FilterBuilder />
</FilterSphereProvider>
);
}

The theme is a set of components and templates that are used to render the Filter Sphere. You can see the constructor of the theme by clicking on the following tabs.

Button
Select
Select
Input
Button
Button
Button

You can override the components to customize the appearance of the Filter Sphere. The components include: Button, Input, Select and MultipleSelect.