Footer Block
The Footer Component is a fully customizable and accessible footer section built with React and TypeScript. It provides a complete website footer interface with modern design patterns, logo display, content sections, and flexible customization options. Built on top of MUI components for consistent styling.
π Installationβ
npm install @nodeblocks/frontend-footer-block@0.2.0
π Usageβ
import {Footer} from '@nodeblocks/frontend-footer-block';
- Basic Usage
- Advanced Usage
function SimpleFooter() { return ( <Footer logoSrc="/img/icon-small.png" content={ <div> <p>Your trusted partner for business solutions.</p> <p>Contact us: info@example.com | +1 (555) 123-4567</p> </div> } copyright="Β© 2024 Your Company Name. All rights reserved." > <Footer.Logo /> <Footer.Content /> <Footer.Copyright /> </Footer> ); }
function AdvancedFooter() { return ( <Footer logoSrc="/img/icon-small.png" content={ <div> <p>Your trusted partner for business solutions.</p> <p>Contact us: info@example.com | +1 (555) 123-4567</p> </div> } copyright="Β© 2024 Your Company Name. All rights reserved." sx={{ bgcolor: '#1e293b', color: '#f1f5f9', }} > {({defaultBlocks}) => { const socialLinks = ( <div style={{ display: 'flex', gap: '16px', alignItems: 'center', }} > <a href="#twitter" style={{color: '#94a3b8', textDecoration: 'none'}}> Twitter </a> <a href="#linkedin" style={{color: '#94a3b8', textDecoration: 'none'}}> LinkedIn </a> <a href="#github" style={{color: '#94a3b8', textDecoration: 'none'}}> GitHub </a> </div> ); const richContent = ( <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '24px', padding: '16px 0', }} > <div> <h4 style={{ color: '#f1f5f9', marginBottom: '12px', fontSize: '14px', fontWeight: '600', }} > Company </h4> <ul style={{listStyle: 'none', padding: 0, margin: 0}}> <li style={{marginBottom: '8px'}}> <a href="#about" style={{ color: '#94a3b8', textDecoration: 'none', fontSize: '14px', }} > About Us </a> </li> <li style={{marginBottom: '8px'}}> <a href="#careers" style={{ color: '#94a3b8', textDecoration: 'none', fontSize: '14px', }} > Careers </a> </li> <li style={{marginBottom: '8px'}}> <a href="#press" style={{ color: '#94a3b8', textDecoration: 'none', fontSize: '14px', }} > Press </a> </li> </ul> </div> <div> <h4 style={{ color: '#f1f5f9', marginBottom: '12px', fontSize: '14px', fontWeight: '600', }} > Contact </h4> <p style={{ color: '#94a3b8', margin: '0 0 8px 0', fontSize: '14px', }} > info@example.com </p> <p style={{ color: '#94a3b8', margin: '0 0 8px 0', fontSize: '14px', }} > +1 (555) 123-4567 </p> <p style={{color: '#94a3b8', margin: 0, fontSize: '14px'}}>123 Business St, City</p> </div> </div> ); return { blocks: { ...defaultBlocks, socialLinks, content: richContent, copyright: ( <div style={{ borderTop: '1px solid #334155', paddingTop: '16px', marginTop: '8px', display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: '12px', }} > <span style={{color: '#64748b', fontSize: '13px'}}>Β© 2024 Custom Company. All rights reserved.</span> <div style={{display: 'flex', gap: '16px', fontSize: '13px'}}> <a href="#privacy" style={{color: '#64748b', textDecoration: 'none'}}> Privacy </a> <a href="#terms" style={{color: '#64748b', textDecoration: 'none'}}> Terms </a> <a href="#cookies" style={{color: '#64748b', textDecoration: 'none'}}> Cookies </a> </div> </div> ), }, blockOrder: ['logo', 'socialLinks', 'content', 'copyright'], }; }} </Footer> ); }
π§ Props Referenceβ
Main Component Propsβ
| Prop | Type | Default | Description |
|---|---|---|---|
logoSrc | string | Required | URL or path to the logo image to display in the footer |
content | ReactNode | Required | The main content section of the footer (can include text, links, etc.) |
copyright | ReactNode | Required | Copyright text or component to display at the bottom of the footer |
spacing | number | string | 2 | Spacing between child elements (MUI Stack spacing) |
className | string | undefined | Additional CSS class name for styling the footer container |
sx | SxProps<Theme> | { backgroundColor: 'primary.main', color: 'primary.contrastText', py: 3, px: 2, typography: 'body2' } | MUI system props for custom styling |
children | BlocksOverride | undefined | Custom block components to override default rendering |
Note: This component inherits all MUI Stack component props (rendered as component="footer").
Sub-Componentsβ
The Footer component provides several sub-components. All sub-components receive their default values from the main component's context and can override these values through props.
Footer.Logoβ
Renders the footer logo inside a MUI Box container.
| Prop | Type | Default | Description |
|---|---|---|---|
logoSrc | string | Context value | URL or path to the logo image (overrides context logoSrc) |
className | string | undefined | Additional CSS class name for styling |
sx | SxProps<Theme> | { pb: 0.5 } | MUI system props for custom styling |
Note: This component inherits all MUI Box component props. The logo is rendered as an <img> element with alt="Footer logo" inside the Box.
Footer.Contentβ
Renders the footer content section using MUI Box.
| Prop | Type | Default | Description |
|---|---|---|---|
content | ReactNode | Context value | Content to display (overrides context content) |
children | ReactNode | undefined | Alternative way to provide content (used if content is not provided) |
className | string | undefined | Additional CSS class name for styling |
sx | SxProps<Theme> | undefined | MUI system props for custom styling |
Note: This component inherits all MUI Box component props. Priority: content prop > children prop.
Footer.Copyrightβ
Renders the copyright section using MUI Box.
| Prop | Type | Default | Description |
|---|---|---|---|
copyright | ReactNode | Context value | Copyright content to display (overrides context copyright) |
children | ReactNode | undefined | Alternative way to provide copyright content |
className | string | undefined | Additional CSS class name for styling |
sx | SxProps<Theme> | undefined | MUI system props for custom styling |
Note: This component inherits all MUI Box component props. Priority: copyright prop > children prop.
π¨ Configuration examplesβ
Custom Background Stylingβ
<Footer
logoSrc="/logo.svg"
content={<p>Footer content</p>}
copyright="Β© 2024 Company"
sx={{
bgcolor: 'grey.900',
color: 'grey.100',
py: 4,
px: 3,
}}
/>
Custom Logo Container Stylingβ
<Footer.Logo
sx={{
pb: 2,
'& img': {
maxHeight: 40,
width: 'auto',
},
}}
/>
Custom Copyright with Borderβ
<Footer.Copyright
sx={{
pt: 2,
mt: 2,
borderTop: '1px solid',
borderColor: 'grey.800',
}}
/>
π§ TypeScript Supportβ
Full TypeScript support with comprehensive type definitions:
import {Footer} from '@nodeblocks/frontend-footer-block';
import {StackProps, BoxProps} from '@mui/material';
import {ReactNode} from 'react';
// Main component props extend MUI StackProps
interface FooterProps extends Omit<StackProps, 'content' | 'children'> {
logoSrc: string;
content: ReactNode;
copyright: ReactNode;
children?: BlocksOverride;
}
// Context type (values passed to all sub-components)
interface FooterContextValue {
logoSrc: string;
copyright: ReactNode;
content: ReactNode;
}
// Example with typed props
function TypedFooter() {
return (
<Footer
logoSrc="/assets/logo.svg"
content={
<div>
<p>Contact: info@example.com</p>
<p>Phone: +1 (555) 123-4567</p>
</div>
}
copyright="Β© 2024 Company Name. All rights reserved."
spacing={3}
sx={{
bgcolor: 'grey.900',
color: 'grey.100',
}}
>
<Footer.Logo sx={{pb: 1}} />
<Footer.Content />
<Footer.Copyright sx={{pt: 2, borderTop: '1px solid', borderColor: 'grey.800'}} />
</Footer>
);
}
π Notesβ
- The component uses MUI's
Stackrendered as afooterelement with defaultspacing={2} - Default styling includes
backgroundColor: 'primary.main',color: 'primary.contrastText', padding (py: 3, px: 2), andtypography: 'body2' - Footer.Logo renders an
<img>element inside a Box withalt="Footer logo" - Footer.Content and Footer.Copyright support both context values and direct children
- All sub-components support the
sxprop for MUI system styling - Block override pattern allows inserting custom blocks and reordering
Built with β€οΈ using React, TypeScript, and MUI.