
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@react-md/layout
Advanced tools
This package is used to configure most of react-md as well as create some pre-defined layouts
Create your app's layout and configure all of react-md in one place. There are
eight different types of layouts supported that change automatically based on
the window size and have reasonable defaults to get you started. The base layout
will create a persistent navigation tree with a fixed header on desktop, while
the navigation tree will be toggleable in a sliding sheet on mobile.
npm install --save @react-md/layout
Since this package is more for general layout and configuration of components, it is highlight recommended to install the following packages as well:
npm install --save @react-md/app-bar \
@react-md/button \
@react-md/dialog \
@react-md/icon \
@react-md/list \
@react-md/sheet \
@react-md/states \
@react-md/theme \
@react-md/tooltip \
@react-md/transition \
@react-md/typography \
@react-md/utils
You should check out the full documentation for live examples and more customization information, but an example usage is shown below.
The main exports for this package are the Configuration component, Layout
component, and useLayoutNavigation hook. The Configuration component should
be mounted near the root of your app as it is a nice wrapper for all the
required React Context providers to work within react-md.
import React from "react";
import { render } from "react-dom";
import { Configuration } from "@react-md/layout";
import App from "./App";
render(
<Configuration>
<App />
</Configuration>,
document.getElementById("root")
);
Once your app has the base Configuration, you can create your base layout with
the Layout component along with a navigation tree by using the
useLayoutNavigation hook. The useLayoutNavigation hook requires you to pass
your navItems along with the current pathname to work correctly. This means
you'll want to get the pathname from your favorite routing library
(react-router for example) so
that the current route will automatically be selected.
import React, { ReactElement } from "react";
import {
Layout,
LayoutNavigationTree,
useLayoutNavigation,
} from "@react-md/layout";
import {
AppsSVGIcon,
BookSVGIcon,
HomeSVGIcon,
MenuSVGIcon,
TVSVGIcon,
} from "@react-md/material-icons";
import { Text } from "@react-md/typography";
import {
BrowserRouter,
Link,
Route,
Switch,
useLocation,
} from "react-router-dom";
const navItems: LayoutNavigationTree = {
"/": {
itemId: "/",
parentId: null,
children: "Home",
leftAddon: <HomeSVGIcon />,
to: "/",
},
"/route-1": {
itemId: "/route-1",
parentId: null,
children: "Route 1",
leftAddon: <TVSVGIcon />,
to: "/route-1",
},
"/route-2": {
itemId: "/route-2",
parentId: null,
children: "Route 2",
leftAddon: <AppsSVGIcon />,
to: "/route-2",
},
"/route-3": {
itemId: "/route-3",
parentId: null,
children: "Route 3",
leftAddon: <BookSVGIcon />,
to: "/route-3",
},
};
function Home(): ReactElement {
return <Text>Home Page</Text>;
}
function Route1(): ReactElement {
return <Text>First Route</Text>;
}
function Route2(): ReactElement {
return <Text>Second Route</Text>;
}
function Route3(): ReactElement {
return <Text>Third Route</Text>;
}
function App(): ReactElement {
const { pathname } = useLocation();
return (
<Layout
title="Example Title"
navHeaderTitle="Example Nav Title"
treeProps={useLayoutNavigation(navItems, pathname, Link)}
>
<Switch>
<Route path="/route-1" component={Route1} />
<Route path="/route-2" component={Route2} />
<Route path="/route-3" component={Route3} />
<Route path="/" component={Home} />
</Switch>
</Layout>
);
}
export default function MyApp(): ReactElement {
return (
<BrowserRouter>
<App />
</BrowserRouter>
);
}
FAQs
This package is used to configure most of react-md as well as create some pre-defined layouts
The npm package @react-md/layout receives a total of 1,248 weekly downloads. As such, @react-md/layout popularity was classified as popular.
We found that @react-md/layout demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.