Icon
The Icon component isn’t really a visual editing component—rather, it renders an SVG icon that users choose through a sidebar IconSelector control.
The component accepts an icon prop of type Icon, matching what’s returned by an IconSelector sidebar control. By rendering an inline <svg>, it offers both performance (avoiding GET requests) and flexibility. You can customize it with any className, width, height, or other SVG props, and even preprocess the file before rendering.
Usage Example
Section titled “Usage Example”// Import from 'react-bricks/rsc/client' for Server componentsimport { Icon } from 'react-bricks/frontend'...
<Icon icon={icon} width={32} height={32} className="text-pink-500 hover:text-pink-700" title="My Icon" description="Description for my Icon" fillOpacity={0.5}/>Properties
Section titled “Properties”Here’s the (simplified) TypeScript interface for the props of the Icon component, which inherits all the props of a normal SVG, like className, width, height, etc.:
interface IconProps extends React.SVGProps<SVGElement> { icon: types.Icon description?: string preProcessor?: (code: string) => string title?: string | null}Properties definition
Section titled “Properties definition”Preprocessor example
Section titled “Preprocessor example”Here’s an example of using preProcessor to process the SVG content.
preProcessor={(code) => code.replace(/fill=".*?"/g, 'fill="currentColor"')}In case of icons from an IconSelector the previous code would not be needed, as icons have already fill="currentColor" for any path.
